Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2022-12-04 03:49:49
Exec Total Coverage
Lines: 1296 3881 33.4%
Functions: 110 335 32.8%
Branches: 583 2734 21.3%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 9 #include "zc_sys.h"
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte disable_direct_updating;
90 byte use_dwm_flush;
91 byte use_save_indicator;
92 byte midi_patch_fix;
93 bool midi_paused=false;
94 int32_t paused_midi_pos = 0;
95 byte midi_suspended = 0;
96 byte callback_switchin = 0;
97 byte zc_192b163_warp_compatibility;
98 char modulepath[2048];
99 byte epilepsyFlashReduction;
100 signed char pause_in_background_menu_init = 0;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
9 byte pause_in_background = 0;
102 bool is_sys_pal = false;
103 extern PALETTE* hw_palette;
104 extern bool update_hw_pal;
105 extern const char* dmaplist(int32_t index, int32_t* list_size);
106
107
108 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
109 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
110 //extern byte refresh_select_screen;
111 //extern movingblock mblock2; //mblock[4]?
112 //extern int32_t db;
113
114 static const char *ZC_str = "Zelda Classic";
115 extern char save_file_name[1024];
116 #ifdef ALLEGRO_DOS
117 const char *qst_dir_name = "dos_qst_dir";
118 #elif defined(ALLEGRO_WINDOWS)
119 const char *qst_dir_name = "win_qst_dir";
120 static const char *qst_module_name = "current_module";
121 #elif defined(ALLEGRO_LINUX)
122 const char *qst_dir_name = "linux_qst_dir";
123 static const char *qst_module_name = "current_module";
124 #elif defined(__APPLE__)
125 const char *qst_dir_name = "osx_qst_dir";
126 static const char *qst_module_name = "current_module";
127 #endif
128 #ifdef ALLEGRO_LINUX
129 static const char *samplepath = "samplesoundset/patches.dat";
130 #endif
131 char qst_files_path[2048];
132
133 #ifdef _MSC_VER
134 #define getcwd _getcwd
135 #endif
136
137 bool rF11();
138 bool rI();
139 bool rQ();
140 bool zc_key_pressed();
141
142 #ifdef _WIN32
143
144 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
145 extern "C"
146 {
147 typedef HRESULT(WINAPI *t_DwmFlush)();
148 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
149 }
150
151 void do_DwmFlush()
152 {
153 static HMODULE shell = LoadLibrary("dwmapi.dll");
154
155 if(!shell)
156 return;
157
158 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
159 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
160
161 BOOL enabled;
162 isEnabled(&enabled);
163
164 if(isEnabled)
165 flush();
166 }
167
168 #endif // _WIN32
169
170 // Dialogue largening
171 void large_dialog(DIALOG *d)
172 {
173 large_dialog(d, 1.5);
174 }
175
176 void large_dialog(DIALOG *d, float RESIZE_AMT)
177 {
178 if(!d[0].d1)
179 {
180 d[0].d1 = 1;
181 int32_t oldwidth = d[0].w;
182 int32_t oldheight = d[0].h;
183 int32_t oldx = d[0].x;
184 int32_t oldy = d[0].y;
185 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
186 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
187 d[0].w = int32_t(d[0].w*RESIZE_AMT);
188 d[0].h = int32_t(d[0].h*RESIZE_AMT);
189
190 for(int32_t i=1; d[i].proc !=NULL; i++)
191 {
192 // Place elements horizontally
193 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
194 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
195
196 if(d[i].proc != d_stringloader)
197 {
198 if(d[i].proc==d_bitmap_proc)
199 {
200 d[i].w *= 2;
201 }
202 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
203 }
204
205 // Place elements vertically
206 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
207 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
208
209 // Vertically resize elements
210 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
211 {
212 d[i].h = int32_t((double)d[i].h*1.5);
213 }
214 else if(d[i].proc == jwin_droplist_proc)
215 {
216 d[i].y += int32_t((double)d[i].h*0.25);
217 d[i].h = int32_t((double)d[i].h*1.25);
218 }
219 else if(d[i].proc==d_bitmap_proc)
220 {
221 d[i].h *= 2;
222 }
223 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
224
225 // Fix frames
226 if(d[i].proc == jwin_frame_proc)
227 {
228 d[i].x++;
229 d[i].y++;
230 d[i].w-=4;
231 d[i].h-=4;
232 }
233 }
234 }
235
236 for(int32_t i=1; d[i].proc!=NULL; i++)
237 {
238 if(d[i].proc==jwin_slider_proc)
239 continue;
240
241 // Bigger font
242 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
243
244 if(!d[i].dp2 && bigfontproc)
245 {
246 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
247 d[i].dp2 = lfont_l;
248 }
249 else if(!bigfontproc)
250 {
251 // ((ListData *)d[i].dp)->font = &sfont3;
252 ((ListData *)d[i].dp)->font = &lfont_l;
253 }
254
255 // Make checkboxes work
256 if(d[i].proc == jwin_check_proc)
257 d[i].proc = jwin_checkfont_proc;
258 else if(d[i].proc == jwin_radio_proc)
259 d[i].proc = jwin_radiofont_proc;
260 }
261
262 jwin_center_dialog(d);
263 }
264
265
266 /**********************************/
267 /******** System functions ********/
268 /**********************************/
269
270 static char cfg_sect[] = "zeldadx"; //We need to rename this.
271
272 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
273 {
274 return D_O_K;
275 }
276
277 9 void load_game_configs()
278 {
279 //set_config_file("zc.cfg"); //shift back when done
280 //load the module
281 9 strcpy(moduledata.module_name,get_config_string("ZCMODULE",qst_module_name,"classic.zmod"));
282 9 joystick_index = zc_get_config(cfg_sect,"joystick_index",0);
283 9 js_stick_1_x_stick = zc_get_config(cfg_sect,"js_stick_1_x_stick",0);
284 9 js_stick_1_x_axis = zc_get_config(cfg_sect,"js_stick_1_x_axis",0);
285 9 js_stick_1_x_offset = zc_get_config(cfg_sect,"js_stick_1_x_offset",0) ? 128 : 0;
286 9 js_stick_1_y_stick = zc_get_config(cfg_sect,"js_stick_1_y_stick",0);
287 9 js_stick_1_y_axis = zc_get_config(cfg_sect,"js_stick_1_y_axis",1);
288 9 js_stick_1_y_offset = zc_get_config(cfg_sect,"js_stick_1_y_offset",0) ? 128 : 0;
289 9 js_stick_2_x_stick = zc_get_config(cfg_sect,"js_stick_2_x_stick",1);
290 9 js_stick_2_x_axis = zc_get_config(cfg_sect,"js_stick_2_x_axis",0);
291 9 js_stick_2_x_offset = zc_get_config(cfg_sect,"js_stick_2_x_offset",0) ? 128 : 0;
292 9 js_stick_2_y_stick = zc_get_config(cfg_sect,"js_stick_2_y_stick",1);
293 9 js_stick_2_y_axis = zc_get_config(cfg_sect,"js_stick_2_y_axis",1);
294 9 js_stick_2_y_offset = zc_get_config(cfg_sect,"js_stick_2_y_offset",0) ? 128 : 0;
295 9 analog_movement = (zc_get_config(cfg_sect,"analog_movement",1));
296
297 //cheat modifier keya
298 9 cheat_modifier_keys[0] = zc_get_config(cfg_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
299 9 cheat_modifier_keys[1] = zc_get_config(cfg_sect,"key_cheatmod_a2",0);
300 9 cheat_modifier_keys[2] = zc_get_config(cfg_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
301 9 cheat_modifier_keys[3] = zc_get_config(cfg_sect,"key_cheatmod_b2",0);
302
303
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
304 joystick_index = 0;
305
306 9 Akey = zc_get_config(cfg_sect,"key_a",KEY_Z);
307 9 Bkey = zc_get_config(cfg_sect,"key_b",KEY_X);
308 9 Skey = zc_get_config(cfg_sect,"key_s",KEY_ENTER);
309 9 Lkey = zc_get_config(cfg_sect,"key_l",KEY_Q);
310 9 Rkey = zc_get_config(cfg_sect,"key_r",KEY_W);
311 9 Pkey = zc_get_config(cfg_sect,"key_p",KEY_SPACE);
312 9 Exkey1 = zc_get_config(cfg_sect,"key_ex1",KEY_A);
313 9 Exkey2 = zc_get_config(cfg_sect,"key_ex2",KEY_S);
314 9 Exkey3 = zc_get_config(cfg_sect,"key_ex3",KEY_D);
315 9 Exkey4 = zc_get_config(cfg_sect,"key_ex4",KEY_C);
316
317 9 DUkey = zc_get_config(cfg_sect,"key_up", KEY_UP);
318 9 DDkey = zc_get_config(cfg_sect,"key_down", KEY_DOWN);
319 9 DLkey = zc_get_config(cfg_sect,"key_left", KEY_LEFT);
320 9 DRkey = zc_get_config(cfg_sect,"key_right",KEY_RIGHT);
321
322 9 Abtn = zc_get_config(cfg_sect,"btn_a",2);
323 9 Bbtn = zc_get_config(cfg_sect,"btn_b",1);
324 9 Sbtn = zc_get_config(cfg_sect,"btn_s",10);
325 9 Mbtn = zc_get_config(cfg_sect,"btn_m",9);
326 9 Lbtn = zc_get_config(cfg_sect,"btn_l",5);
327 9 Rbtn = zc_get_config(cfg_sect,"btn_r",6);
328 9 Pbtn = zc_get_config(cfg_sect,"btn_p",12);
329 9 Exbtn1 = zc_get_config(cfg_sect,"btn_ex1",7);
330 9 Exbtn2 = zc_get_config(cfg_sect,"btn_ex2",8);
331 9 Exbtn3 = zc_get_config(cfg_sect,"btn_ex3",4);
332 9 Exbtn4 = zc_get_config(cfg_sect,"btn_ex4",3);
333
334 9 DUbtn = zc_get_config(cfg_sect,"btn_up",13);
335 9 DDbtn = zc_get_config(cfg_sect,"btn_down",14);
336 9 DLbtn = zc_get_config(cfg_sect,"btn_left",15);
337 9 DRbtn = zc_get_config(cfg_sect,"btn_right",16);
338
339 9 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
340
341 9 digi_volume = zc_get_config(cfg_sect,"digi",248);
342 9 midi_volume = zc_get_config(cfg_sect,"midi",255);
343 9 sfx_volume = zc_get_config(cfg_sect,"sfx",248);
344 9 emusic_volume = zc_get_config(cfg_sect,"emusic",248);
345 9 pan_style = zc_get_config(cfg_sect,"pan",1);
346 // 1 <= zcmusic_bufsz <= 128
347 9 zcmusic_bufsz = vbound(zc_get_config(cfg_sect,"zcmusic_bufsz",64),1,128);
348 9 volkeys = zc_get_config(cfg_sect,"volkeys",0)!=0;
349 9 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
350 9 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
351 9 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
352 9 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
353 9 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
354 #ifdef __EMSCRIPTEN__
355 if (em_is_mobile()) NameEntryMode = 2;
356 #endif
357 9 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
358 9 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
359 9 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
360 9 title_version = zc_get_config(cfg_sect,"title",2);
361 9 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
362 9 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
363
364 //default - scale x2, 640 x 480
365 9 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
366 9 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
367 9 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
368 9 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
369 9 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
370
371 9 loadlast = zc_get_config(cfg_sect,"load_last",0);
372
373 9 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
374
375 9 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
376
377 //workaround for the 100% CPU bug. -Gleeok
378 #ifdef ALLEGRO_MACOSX //IIRC rest(0) was a mac issue fix.
379 9 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",0);
380 #else
381 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",1);
382 #endif
383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 frame_rest_suggest = zc_min(2, frame_rest_suggest);
384
385 9 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
386
387 #ifdef _WIN32
388 use_debug_console = (byte) zc_get_config(cfg_sect,"debug_console",0);
389 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
390 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
391 console_on_top = (byte) zc_get_config("CONSOLE","console_on_top",0);
392 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
393 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
394
395 // This seems to fix some problems on Windows 7
396 disable_direct_updating = (byte) zc_get_config("graphics","disable_direct_updating",1);
397
398 // This one's for Aero
399 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
400
401 // And this one fixes patches unloading on some MIDI setups
402 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
403 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
404 #else //UNIX
405 9 use_debug_console = false;//(byte) zc_get_config(cfg_sect,"debug_console",0);
406 9 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
407 9 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
408 9 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
409 #endif
410
411 9 char const* default_path = "";
412 9 strcpy(qstdir,get_config_string(cfg_sect,qst_dir_name,default_path));
413
414
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 8 times.
9 if(strlen(qstdir)==0)
415 {
416 1 getcwd(qstdir,2048);
417 1 fix_filename_case(qstdir);
418 1 fix_filename_slashes(qstdir);
419 1 put_backslash(qstdir);
420 1 }
421 else
422 {
423 8 chop_path(qstdir);
424 }
425
426 9 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
427 9 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
428 9 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
429 9 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
430 9 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
431 9 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
432 9 gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
433 9 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
434 9 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
435 9 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
436 9 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
437 9 }
438
439 9 void save_game_configs()
440 {
441 9 packfile_password("");
442
443 9 set_config_string("ZCMODULE",qst_module_name,moduledata.module_name);
444
445 9 set_config_int(cfg_sect,"joystick_index",joystick_index);
446 9 set_config_int(cfg_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
447 9 set_config_int(cfg_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
448 9 set_config_int(cfg_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
449 9 set_config_int(cfg_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
450 9 set_config_int(cfg_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
451 9 set_config_int(cfg_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
452 9 set_config_int(cfg_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
453 9 set_config_int(cfg_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
454 9 set_config_int(cfg_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
455 9 set_config_int(cfg_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
456 9 set_config_int(cfg_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
457 9 set_config_int(cfg_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
458 9 set_config_int(cfg_sect,"analog_movement",analog_movement);
459
460 //cheat modifier keya
461
462 9 set_config_int(cfg_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
463 9 set_config_int(cfg_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
464 9 set_config_int(cfg_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
465 9 set_config_int(cfg_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
466
467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if (!replay_is_replaying())
468 {
469 9 set_config_int(cfg_sect,"key_a",Akey);
470 9 set_config_int(cfg_sect,"key_b",Bkey);
471 9 set_config_int(cfg_sect,"key_s",Skey);
472 9 set_config_int(cfg_sect,"key_l",Lkey);
473 9 set_config_int(cfg_sect,"key_r",Rkey);
474 9 set_config_int(cfg_sect,"key_p",Pkey);
475 9 set_config_int(cfg_sect,"key_ex1",Exkey1);
476 9 set_config_int(cfg_sect,"key_ex2",Exkey2);
477 9 set_config_int(cfg_sect,"key_ex3",Exkey3);
478 9 set_config_int(cfg_sect,"key_ex4",Exkey4);
479 9 set_config_int(cfg_sect,"key_up", DUkey);
480 9 set_config_int(cfg_sect,"key_down", DDkey);
481 9 set_config_int(cfg_sect,"key_left", DLkey);
482 9 set_config_int(cfg_sect,"key_right",DRkey);
483 9 }
484
485 9 set_config_int(cfg_sect,"btn_a",Abtn);
486 9 set_config_int(cfg_sect,"btn_b",Bbtn);
487 9 set_config_int(cfg_sect,"btn_s",Sbtn);
488 9 set_config_int(cfg_sect,"btn_m",Mbtn);
489 9 set_config_int(cfg_sect,"btn_l",Lbtn);
490 9 set_config_int(cfg_sect,"btn_r",Rbtn);
491 9 set_config_int(cfg_sect,"btn_p",Pbtn);
492 9 set_config_int(cfg_sect,"btn_ex1",Exbtn1);
493 9 set_config_int(cfg_sect,"btn_ex2",Exbtn2);
494 9 set_config_int(cfg_sect,"btn_ex3",Exbtn3);
495 9 set_config_int(cfg_sect,"btn_ex4",Exbtn4);
496
497 9 set_config_int(cfg_sect,"btn_up",DUbtn);
498 9 set_config_int(cfg_sect,"btn_down",DDbtn);
499 9 set_config_int(cfg_sect,"btn_left",DLbtn);
500 9 set_config_int(cfg_sect,"btn_right",DRbtn);
501
502 9 set_config_int(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
503
504 9 set_config_int(cfg_sect,"digi",digi_volume);
505 9 set_config_int(cfg_sect,"midi",midi_volume);
506 9 set_config_int(cfg_sect,"sfx",sfx_volume);
507 9 set_config_int(cfg_sect,"emusic",emusic_volume);
508 9 set_config_int(cfg_sect,"pan",pan_style);
509 9 set_config_int(cfg_sect,"zcmusic_bufsz",zcmusic_bufsz);
510 9 set_config_int(cfg_sect,"volkeys",(int32_t)volkeys);
511 9 set_config_int(cfg_sect,"vsync",zc_vsync);
512 9 set_config_int(cfg_sect,"throttlefps", (int32_t)Throttlefps);
513 9 set_config_int(cfg_sect,"translayers",(int32_t)TransLayers);
514 9 set_config_int(cfg_sect,"snapshot_format",SnapshotFormat);
515 9 set_config_int(cfg_sect,"name_entry_mode",NameEntryMode);
516 9 set_config_int(cfg_sect,"showfps",(int32_t)ShowFPS);
517 9 set_config_int(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
518 9 set_config_int(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
519 9 set_config_int(cfg_sect,"drag_aspect",(int32_t)DragAspect);
520 9 set_config_int(cfg_sect,"fastquit",(int32_t)NESquit);
521 9 set_config_int(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
522 9 set_config_int(cfg_sect,"title",title_version);
523 //set_config_int(cfg_sect,"lister_pattern_matching",abc_patternmatch); //Enable once there is a GUI way to toggle this.
524
525
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
526 {
527 int o_window_x, o_window_y;
528 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
529 set_config_int(cfg_sect,"window_x",o_window_x);
530 set_config_int(cfg_sect,"window_y",o_window_y);
531 }
532
533
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
9 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
534 {
535 double monitor_scale = zc_get_monitor_scale();
536 window_width = al_get_display_width(all_get_display()) / monitor_scale;
537 window_height = al_get_display_height(all_get_display()) / monitor_scale;
538 set_config_int(cfg_sect,"window_width",window_width);
539 set_config_int(cfg_sect,"window_height",window_height);
540 }
541
542 9 set_config_int(cfg_sect,"load_last",loadlast);
543 9 chop_path(qstdir);
544 9 set_config_string(cfg_sect,qst_dir_name,qstdir);
545 9 set_config_string("SAVEFILE","save_filename",save_file_name);
546 9 set_config_int(cfg_sect,"ss_enable",ss_enable);
547 9 set_config_int(cfg_sect,"ss_after",ss_after);
548 9 set_config_int(cfg_sect,"ss_speed",ss_speed);
549 9 set_config_int(cfg_sect,"ss_density",ss_density);
550 9 set_config_int(cfg_sect,"heart_beep",heart_beep);
551 9 set_config_int(cfg_sect,"gui_colorset",gui_colorset);
552 9 set_config_int(cfg_sect,"use_sfx_dat",sfxdat);
553 9 set_config_int(cfg_sect,"fullscreen",fullscreen);
554 9 set_config_int(cfg_sect,"color_depth",zc_color_depth);
555 9 set_config_int(cfg_sect,"frame_rest_suggest",frame_rest_suggest);
556 9 set_config_int(cfg_sect,"force_exit",forceExit);
557
558 #ifdef _WIN32
559 set_config_int(cfg_sect,"debug_console",use_debug_console);
560 set_config_int("CONSOLE","print_ZASM",zasm_debugger);
561 set_config_int("CONSOLE","ZScript_Debugger",zscript_debugger);
562 set_config_int("CONSOLE","console_on_top",console_on_top);
563 //set_config_int(cfg_sect,"use_win7_key_fix",use_win7_keyboard_fix);
564 set_config_int(cfg_sect,"zc_win_proc_fix",use_win32_proc);
565 set_config_int("graphics","disable_direct_updating",disable_direct_updating);
566 set_config_int("zeldadx","use_dwm_flush",use_dwm_flush);
567 set_config_int("zeldadx","midi_patch_fix",midi_patch_fix);
568 set_config_int("CONSOLE","monochrome_debuggers",monochrome_console);
569 set_config_int("zeldadx","debug_console",zconsole);
570 #endif
571
572 #ifdef ALLEGRO_LINUX
573 set_config_string("sound","patches",samplepath); // set to sample sound path set for DIGMIDI driver in Linux ~ Takuya
574 #endif
575
576 9 set_config_int(cfg_sect,"save_indicator",use_save_indicator);
577 9 set_config_int(cfg_sect,"zc_192b163_warp_compatibility",zc_192b163_warp_compatibility);
578
579 9 flush_config_file();
580 #ifdef __EMSCRIPTEN__
581 em_sync_fs();
582 #endif
583 9 }
584
585 //----------------------------------------------------------------
586
587 // Timers
588
589 567 void fps_callback()
590 {
591 567 lastfps=framecnt;
592 567 dword tempsecs = fps_secs;
593 567 ++tempsecs;
594 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
595 567 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
596 567 ++fps_secs;
597 567 framecnt=0;
598 567 }
599
600 END_OF_FUNCTION(fps_callback)
601
602 9 int32_t Z_init_timers()
603 {
604 static bool didit = false;
605 const static char *err_str = "Couldn't allocate timer";
606 9 err_str = err_str; //Unused variable warning
607
608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(didit)
609 return 1;
610
611 9 didit = true;
612
613 LOCK_VARIABLE(lastfps);
614 LOCK_VARIABLE(framecnt);
615 LOCK_FUNCTION(fps_callback);
616
617
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
618 return 0;
619
620 9 return 1;
621 9 }
622
623 void Z_remove_timers()
624 {
625 remove_int(fps_callback);
626 }
627
628 //----------------------------------------------------------------
629
630 void go()
631 {
632 scare_mouse();
633 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
634 unscare_mouse();
635 }
636
637 void comeback()
638 {
639 scare_mouse();
640 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
641 unscare_mouse();
642 }
643
644 void dump_pal(BITMAP *dest)
645 {
646 for(int32_t i=0; i<256; i++)
647 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
648 }
649
650 //----------------------------------------------------------------
651
652 //Handles converting the mouse sprite from the .dat file
653 9 void load_mouse()
654 {
655 9 system_pal();
656 9 scare_mouse();
657 9 set_mouse_sprite(NULL);
658
1/2
✓ Branch 0 taken 9 times.
✗ Branch 1 not taken.
9 int32_t sz = vbound(int32_t(16*(is_large ? get_config_float("zeldadx","cursor_scale_large",1.5) : get_config_float("zeldadx","cursor_scale_small",1))),16,80);
659
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 9 times.
45 for(int32_t j = 0; j < 4; ++j)
660 {
661 36 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
662 36 BITMAP* subbmp = create_bitmap_ex(8,16,16);
663
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(zcmouse[j])
664 destroy_bitmap(zcmouse[j]);
665 36 zcmouse[j] = create_bitmap_ex(8,sz,sz);
666 36 clear_bitmap(zcmouse[j]);
667 36 clear_bitmap(tmpbmp);
668 36 clear_bitmap(subbmp);
669 36 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
670
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 36 times.
612 for(int32_t x = 0; x < 16; ++x)
671 {
672
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 576 times.
9792 for(int32_t y = 0; y < 16; ++y)
673 {
674 9216 int32_t color = getpixel(tmpbmp, x, y);
675
5/5
✓ Branch 0 taken 8478 times.
✓ Branch 1 taken 171 times.
✓ Branch 2 taken 198 times.
✓ Branch 3 taken 207 times.
✓ Branch 4 taken 162 times.
9216 switch(color)
676 {
677 case dvc(1):
678 171 color = jwin_pal[jcCURSORMISC];
679 171 break;
680 case dvc(2):
681 198 color = jwin_pal[jcCURSOROUTLINE];
682 198 break;
683 case dvc(3):
684 207 color = jwin_pal[jcCURSORLIGHT];
685 207 break;
686 case dvc(5):
687 162 color = jwin_pal[jcCURSORDARK];
688 162 break;
689 }
690 9216 putpixel(subbmp, x, y, color);
691 9216 }
692 576 }
693
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(sz!=16)
694 36 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
695 else
696 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
697 36 destroy_bitmap(tmpbmp);
698 36 destroy_bitmap(subbmp);
699 36 }
700 9 set_mouse_sprite(zcmouse[0]);
701
702 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
703 9 set_palette(*hw_palette);
704 9 show_mouse(screen);
705 9 show_mouse(NULL);
706
707 9 unscare_mouse();
708 9 game_pal();
709 9 }
710
711 // sets the video mode and initializes the palette and mouse sprite
712 9 bool game_vid_mode(int32_t mode,int32_t wait)
713 {
714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
715 {
716 return false;
717 }
718
719 9 scrx = (resx-320)>>1;
720 9 scry = (resy-240)>>1;
721
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 9 times.
45 for(int32_t q = 0; q < 4; ++q)
722 36 zcmouse[q] = NULL;
723 9 load_mouse();
724 9 set_mouse_sprite(zcmouse[0]);
725
726
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 9 times.
153 for(int32_t i=240; i<256; i++)
727 144 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
728
729 9 set_palette(RAMpal);
730 9 clear_to_color(screen,BLACK);
731
732 9 rest(wait);
733 9 return true;
734 9 }
735
736 void null_quest()
737 {
738 char qstdat_string[2048];
739 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
740 strcat(qstdat_string,"#NESQST_NEW_QST");
741
742 #ifdef __EMSCRIPTEN__
743 // The quest template data file is not included because it's really big and isn't really needed
744 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
745 // which is much smaller.
746 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
747 #endif
748
749 byte skip_flags[4] = { 0 };
750
751 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
752 }
753
754 void init_NES_mode()
755 {
756 /*
757 // qst.dat may not load correctly without this...
758 QHeader.templatepath[0]='\0';
759
760 if(!init_colordata(true, &QHeader, &QMisc))
761 {
762 return;
763 }
764
765 loadfullpal();
766 init_tiles(false, &QHeader);
767 */
768 null_quest();
769 }
770
771 //----------------------------------------------------------------
772
773 qword trianglelines[16]=
774 {
775 0x0000000000000000ULL,
776 0xFD00000000000000ULL,
777 0xFDFD000000000000ULL,
778 0xFDFDFD0000000000ULL,
779 0xFDFDFDFD00000000ULL,
780 0xFDFDFDFDFD000000ULL,
781 0xFDFDFDFDFDFD0000ULL,
782 0xFDFDFDFDFDFDFD00ULL,
783 0xFDFDFDFDFDFDFDFDULL,
784 0x00FDFDFDFDFDFDFDULL,
785 0x0000FDFDFDFDFDFDULL,
786 0x000000FDFDFDFDFDULL,
787 0x00000000FDFDFDFDULL,
788 0x0000000000FDFDFDULL,
789 0x000000000000FDFDULL,
790 0x00000000000000FDULL,
791 };
792
793 word screen_triangles[28][32];
794 /*
795 qword triangles[4][16]= //[direction][value]
796 {
797 {
798 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
799 },
800 {
801 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
802 },
803 {
804 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
805 },
806 {
807 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
808 }
809 };
810 */
811
812
813 /*
814 byte triangles[4][16][8]= //[direction][value][line]
815 {
816 {
817 {
818 0, 0, 0, 0, 0, 0, 0, 0
819 },
820 {
821 1, 0, 0, 0, 0, 0, 0, 0
822 },
823 {
824 2, 1, 0, 0, 0, 0, 0, 0
825 },
826 {
827 3, 2, 1, 0, 0, 0, 0, 0
828 },
829 {
830 4, 3, 2, 1, 0, 0, 0, 0
831 },
832 {
833 5, 4, 3, 2, 1, 0, 0, 0
834 },
835 {
836 6, 5, 4, 3, 2, 1, 0, 0
837 },
838 {
839 7, 6, 5, 4, 3, 2, 1, 0
840 },
841 {
842 8, 7, 6, 5, 4, 3, 2, 1
843 },
844 {
845 8, 8, 7, 6, 5, 4, 3, 2
846 },
847 {
848 8, 8, 8, 7, 6, 5, 4, 3
849 },
850 {
851 8, 8, 8, 8, 7, 6, 5, 4
852 },
853 {
854 8, 8, 8, 8, 8, 7, 6, 5
855 },
856 {
857 8, 8, 8, 8, 8, 8, 7, 6
858 },
859 {
860 8, 8, 8, 8, 8, 8, 8, 7
861 },
862 {
863 8, 8, 8, 8, 8, 8, 8, 8
864 }
865 },
866 {
867 {
868 0, 0, 0, 0, 0, 0, 0, 0
869 },
870 {
871 15, 0, 0, 0, 0, 0, 0, 0
872 },
873 {
874 14, 15, 0, 0, 0, 0, 0, 0
875 },
876 {
877 13, 14, 15, 0, 0, 0, 0, 0
878 },
879 {
880 12, 13, 14, 15, 0, 0, 0, 0
881 },
882 {
883 11, 12, 13, 14, 15, 0, 0, 0
884 },
885 {
886 10, 11, 12, 13, 14, 15, 0, 0
887 },
888 {
889 9, 10, 11, 12, 13, 14, 15, 0
890 },
891 {
892 8, 9, 10, 11, 12, 13, 14, 15
893 },
894 {
895 8, 8, 9, 10, 11, 12, 13, 14
896 },
897 {
898 8, 8, 8, 9, 10, 11, 12, 13
899 },
900 {
901 8, 8, 8, 8, 9, 10, 11, 12
902 },
903 {
904 8, 8, 8, 8, 8, 9, 10, 11
905 },
906 {
907 8, 8, 8, 8, 8, 8, 9, 10
908 },
909 {
910 8, 8, 8, 8, 8, 8, 8, 9
911 },
912 {
913 8, 8, 8, 8, 8, 8, 8, 8
914 }
915 },
916 {
917 {
918 0, 0, 0, 0, 0, 0, 0, 0
919 },
920 {
921 0, 0, 0, 0, 0, 0, 0, 1
922 },
923 {
924 0, 0, 0, 0, 0, 0, 1, 2
925 },
926 {
927 0, 0, 0, 0, 0, 1, 2, 3
928 },
929 {
930 0, 0, 0, 0, 1, 2, 3, 4
931 },
932 {
933 0, 0, 0, 1, 2, 3, 4, 5
934 },
935 {
936 0, 0, 1, 2, 3, 4, 5, 6
937 },
938 {
939 0, 1, 2, 3, 4, 5, 6, 7
940 },
941 {
942 1, 2, 3, 4, 5, 6, 7, 8
943 },
944 {
945 2, 3, 4, 5, 6, 7, 8, 8
946 },
947 {
948 3, 4, 5, 6, 7, 8, 8, 8
949 },
950 {
951 4, 5, 6, 7, 8, 8, 8, 8
952 },
953 {
954 5, 6, 7, 8, 8, 8, 8, 8
955 },
956 {
957 6, 7, 8, 8, 8, 8, 8, 8
958 },
959 {
960 7, 8, 8, 8, 8, 8, 8, 8
961 },
962 {
963 8, 8, 8, 8, 8, 8, 8, 8
964 }
965 },
966 {
967 {
968 0, 0, 0, 0, 0, 0, 0, 0
969 },
970 {
971 0, 0, 0, 0, 0, 0, 0, 15
972 },
973 {
974 0, 0, 0, 0, 0, 0, 15, 14
975 },
976 {
977 0, 0, 0, 0, 0, 15, 14, 13
978 },
979 {
980 0, 0, 0, 0, 15, 14, 13, 12
981 },
982 {
983 0, 0, 0, 15, 14, 13, 12, 11
984 },
985 {
986 0, 0, 15, 14, 13, 12, 11, 10
987 },
988 {
989 0, 15, 14, 13, 12, 11, 10, 9
990 },
991 {
992 15, 14, 13, 12, 11, 10, 9, 8
993 },
994 {
995 14, 13, 12, 11, 10, 9, 8, 8
996 },
997 {
998 13, 12, 11, 10, 9, 8, 8, 8
999 },
1000 {
1001 12, 11, 10, 9, 8, 8, 8, 8
1002 },
1003 {
1004 11, 10, 9, 8, 8, 8, 8, 8
1005 },
1006 {
1007 10, 9, 8, 8, 8, 8, 8, 8
1008 },
1009 {
1010 9, 8, 8, 8, 8, 8, 8, 8
1011 },
1012 {
1013 8, 8, 8, 8, 8, 8, 8, 8
1014 }
1015 }
1016 };
1017 */
1018
1019
1020
1021 /*
1022 for (int32_t blockrow=0; blockrow<30; ++i)
1023 {
1024 for (int32_t linerow=0; linerow<8; ++i)
1025 {
1026 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1027 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
1028 {
1029 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
1030 ++triangleline;
1031 }
1032 }
1033 }
1034 */
1035
1036 // the ULL suffixes are to prevent this warning:
1037 // warning: integer constant is too large for "int32_t" type
1038
1039 qword triangles[4][16][8]= //[direction][value][line]
1040 {
1041 {
1042 {
1043 0x0000000000000000ULL,
1044 0x0000000000000000ULL,
1045 0x0000000000000000ULL,
1046 0x0000000000000000ULL,
1047 0x0000000000000000ULL,
1048 0x0000000000000000ULL,
1049 0x0000000000000000ULL,
1050 0x0000000000000000ULL
1051 },
1052 {
1053 0xFD00000000000000ULL,
1054 0x0000000000000000ULL,
1055 0x0000000000000000ULL,
1056 0x0000000000000000ULL,
1057 0x0000000000000000ULL,
1058 0x0000000000000000ULL,
1059 0x0000000000000000ULL,
1060 0x0000000000000000ULL
1061 },
1062 {
1063 0xFDFD000000000000ULL,
1064 0xFD00000000000000ULL,
1065 0x0000000000000000ULL,
1066 0x0000000000000000ULL,
1067 0x0000000000000000ULL,
1068 0x0000000000000000ULL,
1069 0x0000000000000000ULL,
1070 0x0000000000000000ULL
1071 },
1072 {
1073 0xFDFDFD0000000000ULL,
1074 0xFDFD000000000000ULL,
1075 0xFD00000000000000ULL,
1076 0x0000000000000000ULL,
1077 0x0000000000000000ULL,
1078 0x0000000000000000ULL,
1079 0x0000000000000000ULL,
1080 0x0000000000000000ULL
1081 },
1082 {
1083 0xFDFDFDFD00000000ULL,
1084 0xFDFDFD0000000000ULL,
1085 0xFDFD000000000000ULL,
1086 0xFD00000000000000ULL,
1087 0x0000000000000000ULL,
1088 0x0000000000000000ULL,
1089 0x0000000000000000ULL,
1090 0x0000000000000000ULL
1091 },
1092 {
1093 0xFDFDFDFDFD000000ULL,
1094 0xFDFDFDFD00000000ULL,
1095 0xFDFDFD0000000000ULL,
1096 0xFDFD000000000000ULL,
1097 0xFD00000000000000ULL,
1098 0x0000000000000000ULL,
1099 0x0000000000000000ULL,
1100 0x0000000000000000ULL
1101 },
1102 {
1103 0xFDFDFDFDFDFD0000ULL,
1104 0xFDFDFDFDFD000000ULL,
1105 0xFDFDFDFD00000000ULL,
1106 0xFDFDFD0000000000ULL,
1107 0xFDFD000000000000ULL,
1108 0xFD00000000000000ULL,
1109 0x0000000000000000ULL,
1110 0x0000000000000000ULL
1111 },
1112 {
1113 0xFDFDFDFDFDFDFD00ULL,
1114 0xFDFDFDFDFDFD0000ULL,
1115 0xFDFDFDFDFD000000ULL,
1116 0xFDFDFDFD00000000ULL,
1117 0xFDFDFD0000000000ULL,
1118 0xFDFD000000000000ULL,
1119 0xFD00000000000000ULL,
1120 0x0000000000000000ULL
1121 },
1122 {
1123 0xFDFDFDFDFDFDFDFDULL,
1124 0xFDFDFDFDFDFDFD00ULL,
1125 0xFDFDFDFDFDFD0000ULL,
1126 0xFDFDFDFDFD000000ULL,
1127 0xFDFDFDFD00000000ULL,
1128 0xFDFDFD0000000000ULL,
1129 0xFDFD000000000000ULL,
1130 0xFD00000000000000ULL
1131 },
1132 {
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFDFDULL,
1135 0xFDFDFDFDFDFDFD00ULL,
1136 0xFDFDFDFDFDFD0000ULL,
1137 0xFDFDFDFDFD000000ULL,
1138 0xFDFDFDFD00000000ULL,
1139 0xFDFDFD0000000000ULL,
1140 0xFDFD000000000000ULL
1141 },
1142 {
1143 0xFDFDFDFDFDFDFDFDULL,
1144 0xFDFDFDFDFDFDFDFDULL,
1145 0xFDFDFDFDFDFDFDFDULL,
1146 0xFDFDFDFDFDFDFD00ULL,
1147 0xFDFDFDFDFDFD0000ULL,
1148 0xFDFDFDFDFD000000ULL,
1149 0xFDFDFDFD00000000ULL,
1150 0xFDFDFD0000000000ULL
1151 },
1152 {
1153 0xFDFDFDFDFDFDFDFDULL,
1154 0xFDFDFDFDFDFDFDFDULL,
1155 0xFDFDFDFDFDFDFDFDULL,
1156 0xFDFDFDFDFDFDFDFDULL,
1157 0xFDFDFDFDFDFDFD00ULL,
1158 0xFDFDFDFDFDFD0000ULL,
1159 0xFDFDFDFDFD000000ULL,
1160 0xFDFDFDFD00000000ULL
1161 },
1162 {
1163 0xFDFDFDFDFDFDFDFDULL,
1164 0xFDFDFDFDFDFDFDFDULL,
1165 0xFDFDFDFDFDFDFDFDULL,
1166 0xFDFDFDFDFDFDFDFDULL,
1167 0xFDFDFDFDFDFDFDFDULL,
1168 0xFDFDFDFDFDFDFD00ULL,
1169 0xFDFDFDFDFDFD0000ULL,
1170 0xFDFDFDFDFD000000ULL
1171 },
1172 {
1173 0xFDFDFDFDFDFDFDFDULL,
1174 0xFDFDFDFDFDFDFDFDULL,
1175 0xFDFDFDFDFDFDFDFDULL,
1176 0xFDFDFDFDFDFDFDFDULL,
1177 0xFDFDFDFDFDFDFDFDULL,
1178 0xFDFDFDFDFDFDFDFDULL,
1179 0xFDFDFDFDFDFDFD00ULL,
1180 0xFDFDFDFDFDFD0000ULL
1181 },
1182 {
1183 0xFDFDFDFDFDFDFDFDULL,
1184 0xFDFDFDFDFDFDFDFDULL,
1185 0xFDFDFDFDFDFDFDFDULL,
1186 0xFDFDFDFDFDFDFDFDULL,
1187 0xFDFDFDFDFDFDFDFDULL,
1188 0xFDFDFDFDFDFDFDFDULL,
1189 0xFDFDFDFDFDFDFDFDULL,
1190 0xFDFDFDFDFDFDFD00ULL
1191 },
1192 {
1193 0xFDFDFDFDFDFDFDFDULL,
1194 0xFDFDFDFDFDFDFDFDULL,
1195 0xFDFDFDFDFDFDFDFDULL,
1196 0xFDFDFDFDFDFDFDFDULL,
1197 0xFDFDFDFDFDFDFDFDULL,
1198 0xFDFDFDFDFDFDFDFDULL,
1199 0xFDFDFDFDFDFDFDFDULL,
1200 0xFDFDFDFDFDFDFDFDULL
1201 }
1202 },
1203 {
1204 {
1205 0x0000000000000000ULL,
1206 0x0000000000000000ULL,
1207 0x0000000000000000ULL,
1208 0x0000000000000000ULL,
1209 0x0000000000000000ULL,
1210 0x0000000000000000ULL,
1211 0x0000000000000000ULL,
1212 0x0000000000000000ULL
1213 },
1214 {
1215 0x00000000000000FDULL,
1216 0x0000000000000000ULL,
1217 0x0000000000000000ULL,
1218 0x0000000000000000ULL,
1219 0x0000000000000000ULL,
1220 0x0000000000000000ULL,
1221 0x0000000000000000ULL,
1222 0x0000000000000000ULL
1223 },
1224 {
1225 0x000000000000FDFDULL,
1226 0x00000000000000FDULL,
1227 0x0000000000000000ULL,
1228 0x0000000000000000ULL,
1229 0x0000000000000000ULL,
1230 0x0000000000000000ULL,
1231 0x0000000000000000ULL,
1232 0x0000000000000000ULL
1233 },
1234 {
1235 0x0000000000FDFDFDULL,
1236 0x000000000000FDFDULL,
1237 0x00000000000000FDULL,
1238 0x0000000000000000ULL,
1239 0x0000000000000000ULL,
1240 0x0000000000000000ULL,
1241 0x0000000000000000ULL,
1242 0x0000000000000000ULL
1243 },
1244 {
1245 0x00000000FDFDFDFDULL,
1246 0x0000000000FDFDFDULL,
1247 0x000000000000FDFDULL,
1248 0x00000000000000FDULL,
1249 0x0000000000000000ULL,
1250 0x0000000000000000ULL,
1251 0x0000000000000000ULL,
1252 0x0000000000000000ULL
1253 },
1254 {
1255 0x000000FDFDFDFDFDULL,
1256 0x00000000FDFDFDFDULL,
1257 0x0000000000FDFDFDULL,
1258 0x000000000000FDFDULL,
1259 0x00000000000000FDULL,
1260 0x0000000000000000ULL,
1261 0x0000000000000000ULL,
1262 0x0000000000000000ULL
1263 },
1264 {
1265 0x0000FDFDFDFDFDFDULL,
1266 0x000000FDFDFDFDFDULL,
1267 0x00000000FDFDFDFDULL,
1268 0x0000000000FDFDFDULL,
1269 0x000000000000FDFDULL,
1270 0x00000000000000FDULL,
1271 0x0000000000000000ULL,
1272 0x0000000000000000ULL
1273 },
1274 {
1275 0x00FDFDFDFDFDFDFDULL,
1276 0x0000FDFDFDFDFDFDULL,
1277 0x000000FDFDFDFDFDULL,
1278 0x00000000FDFDFDFDULL,
1279 0x0000000000FDFDFDULL,
1280 0x000000000000FDFDULL,
1281 0x00000000000000FDULL,
1282 0x0000000000000000ULL
1283 },
1284 {
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0x00FDFDFDFDFDFDFDULL,
1287 0x0000FDFDFDFDFDFDULL,
1288 0x000000FDFDFDFDFDULL,
1289 0x00000000FDFDFDFDULL,
1290 0x0000000000FDFDFDULL,
1291 0x000000000000FDFDULL,
1292 0x00000000000000FDULL
1293 },
1294 {
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0xFDFDFDFDFDFDFDFDULL,
1297 0x00FDFDFDFDFDFDFDULL,
1298 0x0000FDFDFDFDFDFDULL,
1299 0x000000FDFDFDFDFDULL,
1300 0x00000000FDFDFDFDULL,
1301 0x0000000000FDFDFDULL,
1302 0x000000000000FDFDULL
1303 },
1304 {
1305 0xFDFDFDFDFDFDFDFDULL,
1306 0xFDFDFDFDFDFDFDFDULL,
1307 0xFDFDFDFDFDFDFDFDULL,
1308 0x00FDFDFDFDFDFDFDULL,
1309 0x0000FDFDFDFDFDFDULL,
1310 0x000000FDFDFDFDFDULL,
1311 0x00000000FDFDFDFDULL,
1312 0x0000000000FDFDFDULL
1313 },
1314 {
1315 0xFDFDFDFDFDFDFDFDULL,
1316 0xFDFDFDFDFDFDFDFDULL,
1317 0xFDFDFDFDFDFDFDFDULL,
1318 0xFDFDFDFDFDFDFDFDULL,
1319 0x00FDFDFDFDFDFDFDULL,
1320 0x0000FDFDFDFDFDFDULL,
1321 0x000000FDFDFDFDFDULL,
1322 0x00000000FDFDFDFDULL
1323 },
1324 {
1325 0xFDFDFDFDFDFDFDFDULL,
1326 0xFDFDFDFDFDFDFDFDULL,
1327 0xFDFDFDFDFDFDFDFDULL,
1328 0xFDFDFDFDFDFDFDFDULL,
1329 0xFDFDFDFDFDFDFDFDULL,
1330 0x00FDFDFDFDFDFDFDULL,
1331 0x0000FDFDFDFDFDFDULL,
1332 0x000000FDFDFDFDFDULL
1333 },
1334 {
1335 0xFDFDFDFDFDFDFDFDULL,
1336 0xFDFDFDFDFDFDFDFDULL,
1337 0xFDFDFDFDFDFDFDFDULL,
1338 0xFDFDFDFDFDFDFDFDULL,
1339 0xFDFDFDFDFDFDFDFDULL,
1340 0xFDFDFDFDFDFDFDFDULL,
1341 0x00FDFDFDFDFDFDFDULL,
1342 0x0000FDFDFDFDFDFDULL
1343 },
1344 {
1345 0xFDFDFDFDFDFDFDFDULL,
1346 0xFDFDFDFDFDFDFDFDULL,
1347 0xFDFDFDFDFDFDFDFDULL,
1348 0xFDFDFDFDFDFDFDFDULL,
1349 0xFDFDFDFDFDFDFDFDULL,
1350 0xFDFDFDFDFDFDFDFDULL,
1351 0xFDFDFDFDFDFDFDFDULL,
1352 0x00FDFDFDFDFDFDFDULL
1353 },
1354 {
1355 0xFDFDFDFDFDFDFDFDULL,
1356 0xFDFDFDFDFDFDFDFDULL,
1357 0xFDFDFDFDFDFDFDFDULL,
1358 0xFDFDFDFDFDFDFDFDULL,
1359 0xFDFDFDFDFDFDFDFDULL,
1360 0xFDFDFDFDFDFDFDFDULL,
1361 0xFDFDFDFDFDFDFDFDULL,
1362 0xFDFDFDFDFDFDFDFDULL
1363 }
1364 },
1365 {
1366 {
1367 0x0000000000000000ULL,
1368 0x0000000000000000ULL,
1369 0x0000000000000000ULL,
1370 0x0000000000000000ULL,
1371 0x0000000000000000ULL,
1372 0x0000000000000000ULL,
1373 0x0000000000000000ULL,
1374 0x0000000000000000ULL
1375 },
1376 {
1377 0x0000000000000000ULL,
1378 0x0000000000000000ULL,
1379 0x0000000000000000ULL,
1380 0x0000000000000000ULL,
1381 0x0000000000000000ULL,
1382 0x0000000000000000ULL,
1383 0x0000000000000000ULL,
1384 0xFD00000000000000ULL
1385 },
1386 {
1387 0x0000000000000000ULL,
1388 0x0000000000000000ULL,
1389 0x0000000000000000ULL,
1390 0x0000000000000000ULL,
1391 0x0000000000000000ULL,
1392 0x0000000000000000ULL,
1393 0xFD00000000000000ULL,
1394 0xFDFD000000000000ULL
1395 },
1396 {
1397 0x0000000000000000ULL,
1398 0x0000000000000000ULL,
1399 0x0000000000000000ULL,
1400 0x0000000000000000ULL,
1401 0x0000000000000000ULL,
1402 0xFD00000000000000ULL,
1403 0xFDFD000000000000ULL,
1404 0xFDFDFD0000000000ULL
1405 },
1406 {
1407 0x0000000000000000ULL,
1408 0x0000000000000000ULL,
1409 0x0000000000000000ULL,
1410 0x0000000000000000ULL,
1411 0xFD00000000000000ULL,
1412 0xFDFD000000000000ULL,
1413 0xFDFDFD0000000000ULL,
1414 0xFDFDFDFD00000000ULL
1415 },
1416 {
1417 0x0000000000000000ULL,
1418 0x0000000000000000ULL,
1419 0x0000000000000000ULL,
1420 0xFD00000000000000ULL,
1421 0xFDFD000000000000ULL,
1422 0xFDFDFD0000000000ULL,
1423 0xFDFDFDFD00000000ULL,
1424 0xFDFDFDFDFD000000ULL
1425 },
1426 {
1427 0x0000000000000000ULL,
1428 0x0000000000000000ULL,
1429 0xFD00000000000000ULL,
1430 0xFDFD000000000000ULL,
1431 0xFDFDFD0000000000ULL,
1432 0xFDFDFDFD00000000ULL,
1433 0xFDFDFDFDFD000000ULL,
1434 0xFDFDFDFDFDFD0000ULL
1435 },
1436 {
1437 0x0000000000000000ULL,
1438 0xFD00000000000000ULL,
1439 0xFDFD000000000000ULL,
1440 0xFDFDFD0000000000ULL,
1441 0xFDFDFDFD00000000ULL,
1442 0xFDFDFDFDFD000000ULL,
1443 0xFDFDFDFDFDFD0000ULL,
1444 0xFDFDFDFDFDFDFD00ULL
1445 },
1446 {
1447 0xFD00000000000000ULL,
1448 0xFDFD000000000000ULL,
1449 0xFDFDFD0000000000ULL,
1450 0xFDFDFDFD00000000ULL,
1451 0xFDFDFDFDFD000000ULL,
1452 0xFDFDFDFDFDFD0000ULL,
1453 0xFDFDFDFDFDFDFD00ULL,
1454 0xFDFDFDFDFDFDFDFDULL
1455 },
1456 {
1457 0xFDFD000000000000ULL,
1458 0xFDFDFD0000000000ULL,
1459 0xFDFDFDFD00000000ULL,
1460 0xFDFDFDFDFD000000ULL,
1461 0xFDFDFDFDFDFD0000ULL,
1462 0xFDFDFDFDFDFDFD00ULL,
1463 0xFDFDFDFDFDFDFDFDULL,
1464 0xFDFDFDFDFDFDFDFDULL
1465 },
1466 {
1467 0xFDFDFD0000000000ULL,
1468 0xFDFDFDFD00000000ULL,
1469 0xFDFDFDFDFD000000ULL,
1470 0xFDFDFDFDFDFD0000ULL,
1471 0xFDFDFDFDFDFDFD00ULL,
1472 0xFDFDFDFDFDFDFDFDULL,
1473 0xFDFDFDFDFDFDFDFDULL,
1474 0xFDFDFDFDFDFDFDFDULL
1475 },
1476 {
1477 0xFDFDFDFD00000000ULL,
1478 0xFDFDFDFDFD000000ULL,
1479 0xFDFDFDFDFDFD0000ULL,
1480 0xFDFDFDFDFDFDFD00ULL,
1481 0xFDFDFDFDFDFDFDFDULL,
1482 0xFDFDFDFDFDFDFDFDULL,
1483 0xFDFDFDFDFDFDFDFDULL,
1484 0xFDFDFDFDFDFDFDFDULL
1485 },
1486 {
1487 0xFDFDFDFDFD000000ULL,
1488 0xFDFDFDFDFDFD0000ULL,
1489 0xFDFDFDFDFDFDFD00ULL,
1490 0xFDFDFDFDFDFDFDFDULL,
1491 0xFDFDFDFDFDFDFDFDULL,
1492 0xFDFDFDFDFDFDFDFDULL,
1493 0xFDFDFDFDFDFDFDFDULL,
1494 0xFDFDFDFDFDFDFDFDULL
1495 },
1496 {
1497 0xFDFDFDFDFDFD0000ULL,
1498 0xFDFDFDFDFDFDFD00ULL,
1499 0xFDFDFDFDFDFDFDFDULL,
1500 0xFDFDFDFDFDFDFDFDULL,
1501 0xFDFDFDFDFDFDFDFDULL,
1502 0xFDFDFDFDFDFDFDFDULL,
1503 0xFDFDFDFDFDFDFDFDULL,
1504 0xFDFDFDFDFDFDFDFDULL
1505 },
1506 {
1507 0xFDFDFDFDFDFDFD00ULL,
1508 0xFDFDFDFDFDFDFDFDULL,
1509 0xFDFDFDFDFDFDFDFDULL,
1510 0xFDFDFDFDFDFDFDFDULL,
1511 0xFDFDFDFDFDFDFDFDULL,
1512 0xFDFDFDFDFDFDFDFDULL,
1513 0xFDFDFDFDFDFDFDFDULL,
1514 0xFDFDFDFDFDFDFDFDULL
1515 },
1516 {
1517 0xFDFDFDFDFDFDFDFDULL,
1518 0xFDFDFDFDFDFDFDFDULL,
1519 0xFDFDFDFDFDFDFDFDULL,
1520 0xFDFDFDFDFDFDFDFDULL,
1521 0xFDFDFDFDFDFDFDFDULL,
1522 0xFDFDFDFDFDFDFDFDULL,
1523 0xFDFDFDFDFDFDFDFDULL,
1524 0xFDFDFDFDFDFDFDFDULL
1525 }
1526 },
1527 {
1528 {
1529 0x0000000000000000ULL,
1530 0x0000000000000000ULL,
1531 0x0000000000000000ULL,
1532 0x0000000000000000ULL,
1533 0x0000000000000000ULL,
1534 0x0000000000000000ULL,
1535 0x0000000000000000ULL,
1536 0x0000000000000000ULL
1537 },
1538 {
1539 0x0000000000000000ULL,
1540 0x0000000000000000ULL,
1541 0x0000000000000000ULL,
1542 0x0000000000000000ULL,
1543 0x0000000000000000ULL,
1544 0x0000000000000000ULL,
1545 0x0000000000000000ULL,
1546 0x00000000000000FDULL
1547 },
1548 {
1549 0x0000000000000000ULL,
1550 0x0000000000000000ULL,
1551 0x0000000000000000ULL,
1552 0x0000000000000000ULL,
1553 0x0000000000000000ULL,
1554 0x0000000000000000ULL,
1555 0x00000000000000FDULL,
1556 0x000000000000FDFDULL
1557 },
1558 {
1559 0x0000000000000000ULL,
1560 0x0000000000000000ULL,
1561 0x0000000000000000ULL,
1562 0x0000000000000000ULL,
1563 0x0000000000000000ULL,
1564 0x00000000000000FDULL,
1565 0x000000000000FDFDULL,
1566 0x0000000000FDFDFDULL
1567 },
1568 {
1569 0x0000000000000000ULL,
1570 0x0000000000000000ULL,
1571 0x0000000000000000ULL,
1572 0x0000000000000000ULL,
1573 0x00000000000000FDULL,
1574 0x000000000000FDFDULL,
1575 0x0000000000FDFDFDULL,
1576 0x00000000FDFDFDFDULL
1577 },
1578 {
1579 0x0000000000000000ULL,
1580 0x0000000000000000ULL,
1581 0x0000000000000000ULL,
1582 0x00000000000000FDULL,
1583 0x000000000000FDFDULL,
1584 0x0000000000FDFDFDULL,
1585 0x00000000FDFDFDFDULL,
1586 0x000000FDFDFDFDFDULL
1587 },
1588 {
1589 0x0000000000000000ULL,
1590 0x0000000000000000ULL,
1591 0x00000000000000FDULL,
1592 0x000000000000FDFDULL,
1593 0x0000000000FDFDFDULL,
1594 0x00000000FDFDFDFDULL,
1595 0x000000FDFDFDFDFDULL,
1596 0x0000FDFDFDFDFDFDULL
1597 },
1598 {
1599 0x0000000000000000ULL,
1600 0x00000000000000FDULL,
1601 0x000000000000FDFDULL,
1602 0x0000000000FDFDFDULL,
1603 0x00000000FDFDFDFDULL,
1604 0x000000FDFDFDFDFDULL,
1605 0x0000FDFDFDFDFDFDULL,
1606 0x00FDFDFDFDFDFDFDULL
1607 },
1608 {
1609 0x00000000000000FDULL,
1610 0x000000000000FDFDULL,
1611 0x0000000000FDFDFDULL,
1612 0x00000000FDFDFDFDULL,
1613 0x000000FDFDFDFDFDULL,
1614 0x0000FDFDFDFDFDFDULL,
1615 0x00FDFDFDFDFDFDFDULL,
1616 0xFDFDFDFDFDFDFDFDULL
1617 },
1618 {
1619 0x000000000000FDFDULL,
1620 0x0000000000FDFDFDULL,
1621 0x00000000FDFDFDFDULL,
1622 0x000000FDFDFDFDFDULL,
1623 0x0000FDFDFDFDFDFDULL,
1624 0x00FDFDFDFDFDFDFDULL,
1625 0xFDFDFDFDFDFDFDFDULL,
1626 0xFDFDFDFDFDFDFDFDULL
1627 },
1628 {
1629 0x0000000000FDFDFDULL,
1630 0x00000000FDFDFDFDULL,
1631 0x000000FDFDFDFDFDULL,
1632 0x0000FDFDFDFDFDFDULL,
1633 0x00FDFDFDFDFDFDFDULL,
1634 0xFDFDFDFDFDFDFDFDULL,
1635 0xFDFDFDFDFDFDFDFDULL,
1636 0xFDFDFDFDFDFDFDFDULL
1637 },
1638 {
1639 0x00000000FDFDFDFDULL,
1640 0x000000FDFDFDFDFDULL,
1641 0x0000FDFDFDFDFDFDULL,
1642 0x00FDFDFDFDFDFDFDULL,
1643 0xFDFDFDFDFDFDFDFDULL,
1644 0xFDFDFDFDFDFDFDFDULL,
1645 0xFDFDFDFDFDFDFDFDULL,
1646 0xFDFDFDFDFDFDFDFDULL
1647 },
1648 {
1649 0x000000FDFDFDFDFDULL,
1650 0x0000FDFDFDFDFDFDULL,
1651 0x00FDFDFDFDFDFDFDULL,
1652 0xFDFDFDFDFDFDFDFDULL,
1653 0xFDFDFDFDFDFDFDFDULL,
1654 0xFDFDFDFDFDFDFDFDULL,
1655 0xFDFDFDFDFDFDFDFDULL,
1656 0xFDFDFDFDFDFDFDFDULL
1657 },
1658 {
1659 0x0000FDFDFDFDFDFDULL,
1660 0x00FDFDFDFDFDFDFDULL,
1661 0xFDFDFDFDFDFDFDFDULL,
1662 0xFDFDFDFDFDFDFDFDULL,
1663 0xFDFDFDFDFDFDFDFDULL,
1664 0xFDFDFDFDFDFDFDFDULL,
1665 0xFDFDFDFDFDFDFDFDULL,
1666 0xFDFDFDFDFDFDFDFDULL
1667 },
1668 {
1669 0x00FDFDFDFDFDFDFDULL,
1670 0xFDFDFDFDFDFDFDFDULL,
1671 0xFDFDFDFDFDFDFDFDULL,
1672 0xFDFDFDFDFDFDFDFDULL,
1673 0xFDFDFDFDFDFDFDFDULL,
1674 0xFDFDFDFDFDFDFDFDULL,
1675 0xFDFDFDFDFDFDFDFDULL,
1676 0xFDFDFDFDFDFDFDFDULL
1677 },
1678 {
1679 0xFDFDFDFDFDFDFDFDULL,
1680 0xFDFDFDFDFDFDFDFDULL,
1681 0xFDFDFDFDFDFDFDFDULL,
1682 0xFDFDFDFDFDFDFDFDULL,
1683 0xFDFDFDFDFDFDFDFDULL,
1684 0xFDFDFDFDFDFDFDFDULL,
1685 0xFDFDFDFDFDFDFDFDULL,
1686 0xFDFDFDFDFDFDFDFDULL
1687 }
1688 }
1689 };
1690
1691 int32_t black_opening_count=0;
1692 int32_t black_opening_x,black_opening_y;
1693 int32_t black_opening_shape;
1694
1695 38 int32_t choose_opening_shape()
1696 {
1697 // First, count how many bits are set
1698 38 int32_t numBits=0;
1699 int32_t bitCounter;
1700
1701
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 38 times.
228 for(int32_t i=0; i<bosMAX; i++)
1702 {
1703
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 if(COOLSCROLL&(1<<i))
1704 38 numBits++;
1705 190 }
1706
1707 // Shouldn't happen...
1708
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(numBits==0)
1709 return bosCIRCLE;
1710
1711 // Pick a bit
1712 38 bitCounter=zc_rand()%numBits+1;
1713
1714
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 for(int32_t i=0; i<bosMAX; i++)
1715 {
1716 // If this bit is set, decrement the bit counter
1717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(COOLSCROLL&(1<<i))
1718 38 bitCounter--;
1719
1720 // When the counter hits 0, return a value based on
1721 // which bit it stopped on.
1722 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1723
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(bitCounter==0)
1724 38 return i;
1725 }
1726
1727 // Shouldn't be necessary, but the compiler might complain, at least
1728 return bosCIRCLE;
1729 38 }
1730
1731 8 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1732 {
1733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1734
1735 8 int32_t w=256, h=224;
1736 8 int32_t blockrows=28, blockcolumns=32;
1737 8 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1738
1739
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 8 times.
232 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1740 {
1741
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 224 times.
7392 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1742 {
1743
2/2
✓ Branch 0 taken 3738 times.
✓ Branch 1 taken 3430 times.
7168 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1744 7168 }
1745 224 }
1746
1747 8 black_opening_count = 66;
1748 8 black_opening_x = x;
1749 8 black_opening_y = y;
1750 8 lensclk = 0;
1751 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1752
1753
1754
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(black_opening_shape == bosFADEBLACK)
1755 {
1756 refreshTints();
1757 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1758 }
1759
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(wait)
1760 {
1761 FFCore.warpScriptCheck();
1762 for(int32_t i=0; i<66; i++)
1763 {
1764 draw_screen(tmpscr);
1765 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1766 syskeys();
1767 advanceframe(true);
1768
1769 if(Quit)
1770 {
1771 break;
1772 }
1773 }
1774 }
1775 8 }
1776
1777 30 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1778 {
1779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1780
1781 30 int32_t w=256, h=224;
1782 30 int32_t blockrows=28, blockcolumns=32;
1783 30 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1784
1785
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 30 times.
870 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1786 {
1787
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 840 times.
27720 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1788 {
1789
2/2
✓ Branch 0 taken 11253 times.
✓ Branch 1 taken 15627 times.
26880 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1790 26880 }
1791 840 }
1792
1793 30 black_opening_count = -66;
1794 30 black_opening_x = x;
1795 30 black_opening_y = y;
1796 30 lensclk = 0;
1797
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(black_opening_shape == bosFADEBLACK)
1798 {
1799 refreshTints();
1800 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1801 }
1802
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 25 times.
30 if(wait)
1803 {
1804 25 FFCore.warpScriptCheck();
1805
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 1650 times.
1675 for(int32_t i=0; i<66; i++)
1806 {
1807 1650 draw_screen(tmpscr);
1808 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1809 1650 syskeys();
1810 1650 advanceframe(true);
1811
1812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1650 times.
1650 if(Quit)
1813 {
1814 break;
1815 }
1816 1650 }
1817 25 }
1818 30 }
1819
1820 2508 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1821 {
1822 2508 clear_to_color(tmp_scr,BLACK);
1823 2508 int32_t w=256, h=224;
1824
1825
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2508 times.
2508 switch(black_opening_shape)
1826 {
1827 case bosOVAL:
1828 {
1829 double new_w=(w/2)+abs(w/2-x);
1830 double new_h=(h/2)+abs(h/2-y);
1831 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1832 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1833 break;
1834 }
1835
1836 case bosTRIANGLE:
1837 {
1838 double new_w=(w/2)+abs(w/2-x);
1839 double new_h=(h/2)+abs(h/2-y);
1840 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1841 double P2= (PI/2);
1842 double P23=(2*PI/3);
1843 double P43=(4*PI/3);
1844 double Pa= (-4*PI*a/(3*max_a));
1845 double angle=P2+Pa;
1846 double a0=angle;
1847 double a2=angle+P23;
1848 double a4=angle+P43;
1849 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1850 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1851 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1852 0);
1853 break;
1854 }
1855
1856 case bosSMAS:
1857 {
1858 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1859
1860 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1861 {
1862 for(int32_t linerow=0; linerow<8; ++linerow)
1863 {
1864 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1865
1866 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1867 {
1868 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1869 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1870 [linerow];
1871 ++triangleline;
1872
1873 if(linerow==0)
1874 {
1875 }
1876 }
1877 }
1878 }
1879
1880 break;
1881 }
1882
1883 case bosFADEBLACK:
1884 {
1885 if(black_opening_count<0)
1886 {
1887 black_fade(zc_min(-black_opening_count,63));
1888 }
1889 else if(black_opening_count>0)
1890 {
1891 black_fade(63-zc_max(black_opening_count-3,0));
1892 }
1893 else black_fade(0);
1894 return; //no blitting from tmp_scr!
1895 }
1896
1897 2508 case bosCIRCLE:
1898 default:
1899 {
1900 2508 double new_w=(w/2)+abs(w/2-x);
1901 2508 double new_h=(h/2)+abs(h/2-y);
1902 2508 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1903 //circlefill(tmp_scr,x,y,a<<3,0);
1904 2508 circlefill(tmp_scr,x,y,r,0);
1905 2508 break;
1906 }
1907 }
1908
1909 2508 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1910 2508 }
1911
1912
1913 void black_fade(int32_t fadeamnt)
1914 {
1915 for(int32_t i=0; i < 0xEF; i++)
1916 {
1917 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1918 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1919 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1920 }
1921
1922 refreshpal = true;
1923 }
1924
1925 //----------------------------------------------------------------
1926
1927 159422 bool item_disabled(int32_t item) //is this item disabled?
1928 {
1929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 159422 times.
159422 return (item>=0 && game->items_off[item] != 0);
1930 }
1931
1932 339782 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1933 {
1934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 339782 times.
339782 if(current_item(item_type, true) >=item)
1935 {
1936 return true;
1937 }
1938
1939 339782 return false;
1940 339782 }
1941
1942 1545880 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1943 {
1944
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 240509 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 71612 times.
✓ Branch 6 taken 930414 times.
✓ Branch 7 taken 301872 times.
✓ Branch 8 taken 1473 times.
1545880 switch(item_type)
1945 {
1946 case itype_bomb:
1947 case itype_sbomb:
1948 {
1949 int32_t itemid = getItemID(itemsbuf, item_type, it);
1950
1951 if(itemid == -1)
1952 return false;
1953
1954 return (game->get_item(itemid));
1955 }
1956
1957 case itype_clock:
1958 {
1959 240509 int32_t itemid = getItemID(itemsbuf, item_type, it);
1960
1961
2/4
✓ Branch 0 taken 240509 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 240509 times.
✗ Branch 3 not taken.
240509 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1962 return (game->get_item(itemid));
1963 240509 return Hero.getClock()?1:0;
1964 }
1965
1966 case itype_key:
1967 return (game->get_keys()>0);
1968
1969 case itype_magiccontainer:
1970 return (game->get_maxmagic()>=game->get_mp_per_block());
1971
1972 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1973 {
1974
1/3
✓ Branch 0 taken 71612 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
71612 switch(it)
1975 {
1976 case -2:
1977 {
1978 for(int32_t i=0; i<MAXLEVELS; i++)
1979 {
1980 if(game->lvlitems[i]&liTRIFORCE)
1981 {
1982 return true;
1983 }
1984 }
1985
1986 return false;
1987 }
1988
1989 case -1:
1990 return (game->lvlitems[dlevel]&liTRIFORCE);
1991
1992 default:
1993
2/4
✓ Branch 0 taken 71612 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 71612 times.
71612 if(it>=0&&it<MAXLEVELS)
1994 {
1995 71612 return (game->lvlitems[it]&liTRIFORCE);
1996 }
1997
1998 break;
1999 }
2000
2001 return 0;
2002 }
2003
2004 case itype_map: //it: -2=any, -1=current level, other=that level
2005 {
2006
1/3
✓ Branch 0 taken 930414 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
930414 switch(it)
2007 {
2008 case -2:
2009 {
2010 for(int32_t i=0; i<MAXLEVELS; i++)
2011 {
2012 if(game->lvlitems[i]&liMAP)
2013 {
2014 return true;
2015 }
2016 }
2017
2018 return false;
2019 }
2020
2021 case -1:
2022 return (game->lvlitems[dlevel]&liMAP)!=0;
2023
2024 default:
2025
2/4
✓ Branch 0 taken 930414 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 930414 times.
930414 if(it>=0&&it<MAXLEVELS)
2026 {
2027 930414 return (game->lvlitems[it]&liMAP)!=0;
2028 }
2029
2030 break;
2031 }
2032
2033 return 0;
2034 }
2035
2036 case itype_compass: //it: -2=any, -1=current level, other=that level
2037 {
2038
1/3
✓ Branch 0 taken 301872 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
301872 switch(it)
2039 {
2040 case -2:
2041 {
2042 for(int32_t i=0; i<MAXLEVELS; i++)
2043 {
2044 if(game->lvlitems[i]&liCOMPASS)
2045 {
2046 return true;
2047 }
2048 }
2049
2050 return false;
2051 }
2052
2053 case -1:
2054 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2055
2056 default:
2057
2/4
✓ Branch 0 taken 301872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 301872 times.
✗ Branch 3 not taken.
301872 if(it>=0&&it<MAXLEVELS)
2058 {
2059 301872 return (game->lvlitems[it]&liCOMPASS)!=0;
2060 }
2061
2062 break;
2063 }
2064 return 0;
2065 }
2066
2067 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2068 {
2069
1/3
✓ Branch 0 taken 1473 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
1473 switch(it)
2070 {
2071 case -2:
2072 {
2073 for(int32_t i=0; i<MAXLEVELS; i++)
2074 {
2075 if(game->lvlitems[i]&liBOSSKEY)
2076 {
2077 return true;
2078 }
2079 }
2080
2081 return false;
2082 }
2083
2084 case -1:
2085 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2086
2087 default:
2088
2/4
✓ Branch 0 taken 1473 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1473 times.
1473 if(it>=0&&it<MAXLEVELS)
2089 {
2090 1473 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2091 }
2092 break;
2093 }
2094 return 0;
2095 }
2096
2097 default:
2098 //it=(1<<(it-1));
2099 /*if (item_type>=itype_max)
2100 {
2101 system_pal();
2102 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2103 game_pal();
2104
2105 return false;
2106 }*/
2107 int32_t itemid = getItemID(itemsbuf, item_type, it);
2108
2109 if(itemid == -1)
2110 return false;
2111
2112 return game->get_item(itemid);
2113 }
2114 1545880 }
2115
2116
2117 4073224 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2118 {
2119
9/9
✓ Branch 0 taken 240509 times.
✓ Branch 1 taken 2149152 times.
✓ Branch 2 taken 240509 times.
✓ Branch 3 taken 240509 times.
✓ Branch 4 taken 240509 times.
✓ Branch 5 taken 240509 times.
✓ Branch 6 taken 240509 times.
✓ Branch 7 taken 240509 times.
✓ Branch 8 taken 240509 times.
4073224 switch(item_type)
2120 {
2121 case itype_clock:
2122 {
2123 240509 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2124
2125
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240509 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240509 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2126 return itemsbuf[maxid].fam_type;
2127
2128 240509 return has_item(itype_clock,1) ? 1 : 0;
2129 }
2130
2131 case itype_key:
2132 240509 return game->get_keys();
2133
2134 case itype_lkey:
2135 240509 return game->lvlkeys[get_dlevel()];
2136
2137 case itype_magiccontainer:
2138 240509 return game->get_maxmagic()/game->get_mp_per_block();
2139
2140 case itype_triforcepiece:
2141 {
2142 240509 int32_t count=0;
2143
2144
2/2
✓ Branch 0 taken 123140608 times.
✓ Branch 1 taken 240509 times.
123381117 for(int32_t i=0; i<MAXLEVELS; i++)
2145 {
2146 123140608 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2147 123140608 }
2148
2149 240509 return count;
2150 }
2151
2152 case itype_map:
2153 {
2154 240509 int32_t count=0;
2155
2156
2/2
✓ Branch 0 taken 123140608 times.
✓ Branch 1 taken 240509 times.
123381117 for(int32_t i=0; i<MAXLEVELS; i++)
2157 {
2158 123140608 count+=(game->lvlitems[i]&liMAP)?1:0;
2159 123140608 }
2160
2161 240509 return count;
2162 }
2163
2164 case itype_compass:
2165 {
2166 240509 int32_t count=0;
2167
2168
2/2
✓ Branch 0 taken 123140608 times.
✓ Branch 1 taken 240509 times.
123381117 for(int32_t i=0; i<MAXLEVELS; i++)
2169 {
2170 123140608 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2171 123140608 }
2172
2173 240509 return count;
2174 }
2175
2176 case itype_bosskey:
2177 {
2178 240509 int32_t count=0;
2179
2180
2/2
✓ Branch 0 taken 123140608 times.
✓ Branch 1 taken 240509 times.
123381117 for(int32_t i=0; i<MAXLEVELS; i++)
2181 {
2182 123140608 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2183 123140608 }
2184
2185 240509 return count;
2186 }
2187
2188 default:
2189 2149152 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2190
2191
2/2
✓ Branch 0 taken 81751 times.
✓ Branch 1 taken 2067401 times.
2149152 if(maxid == -1)
2192 2067401 return 0;
2193
2194 81751 return itemsbuf[maxid].fam_type;
2195 }
2196 4073224 }
2197
2198 3733442 int32_t current_item(int32_t item_type) //item currently being used
2199 {
2200 3733442 return current_item(item_type, true);
2201 }
2202
2203 9 std::map<int32_t, int32_t> itemcache;
2204
2205 // Not actually used by anything at the moment...
2206 void removeFromItemCache(int32_t itemid)
2207 {
2208 itemcache.erase(itemid);
2209 }
2210
2211 842 void flushItemCache()
2212 {
2213 842 itemcache.clear();
2214
2215 //also fix the active subscreen if items were deleted -DD
2216
1/2
✓ Branch 0 taken 842 times.
✗ Branch 1 not taken.
842 if(game != NULL)
2217 {
2218 842 verifyBothWeapons();
2219 842 load_Sitems(&QMisc);
2220 842 }
2221 842 }
2222
2223 // This is used often, so it should be as direct as possible.
2224 132686521 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2225 {
2226
2/2
✓ Branch 0 taken 130171014 times.
✓ Branch 1 taken 2515507 times.
132686521 if(jinx_check)
2227 {
2228
3/4
✓ Branch 0 taken 1485349 times.
✓ Branch 1 taken 1030158 times.
✓ Branch 2 taken 1485349 times.
✗ Branch 3 not taken.
2515507 if(!(HeroSwordClk() || HeroItemClk()))
2229 1485349 jinx_check = false; //not jinxed
2230 2515507 }
2231
4/4
✓ Branch 0 taken 132078144 times.
✓ Branch 1 taken 608377 times.
✓ Branch 2 taken 1026411 times.
✓ Branch 3 taken 131051733 times.
132686521 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2232 {
2233 131051733 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2234
2235
2/2
✓ Branch 0 taken 130621924 times.
✓ Branch 1 taken 429809 times.
131051733 if(res != itemcache.end())
2236 130621924 return res->second;
2237 429809 }
2238
2239 2064597 int32_t result = -1;
2240 2064597 int32_t highestlevel = -1;
2241
2242
2/2
✓ Branch 0 taken 528536832 times.
✓ Branch 1 taken 2064597 times.
530601429 for(int32_t i=0; i<MAXITEMS; i++)
2243 {
2244
5/6
✓ Branch 0 taken 24525097 times.
✓ Branch 1 taken 504011735 times.
✓ Branch 2 taken 154464 times.
✓ Branch 3 taken 24370633 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 154464 times.
528536832 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2245 {
2246
4/4
✓ Branch 0 taken 67116 times.
✓ Branch 1 taken 87348 times.
✓ Branch 2 taken 34691 times.
✓ Branch 3 taken 119773 times.
154464 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2247 {
2248 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2249
2/2
✓ Branch 0 taken 119771 times.
✓ Branch 1 taken 2 times.
119773 if(!checkmagiccost(i))
2250 {
2251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2252 }
2253 119771 }
2254
6/6
✓ Branch 0 taken 86780 times.
✓ Branch 1 taken 67682 times.
✓ Branch 2 taken 11915 times.
✓ Branch 3 taken 55767 times.
✓ Branch 4 taken 55767 times.
✓ Branch 5 taken 11915 times.
154462 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2255 {
2256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11915 times.
11915 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2257 11915 continue;
2258 }
2259
2260
2/2
✓ Branch 0 taken 15043 times.
✓ Branch 1 taken 127504 times.
142547 if(itemsbuf[i].fam_type >= highestlevel)
2261 {
2262 127504 highestlevel = itemsbuf[i].fam_type;
2263 127504 result=i;
2264 127504 }
2265 142547 }
2266 528524915 }
2267
2268
2/2
✓ Branch 0 taken 1030158 times.
✓ Branch 1 taken 1034439 times.
2064597 if(!jinx_check) //Can't cache jinx_check results
2269 1034439 itemcache[itemtype] = result;
2270 2064597 return result;
2271 132686521 }
2272
2273 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2274 131670140 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2275 {
2276 131670140 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2277
2/2
✓ Branch 0 taken 1499126 times.
✓ Branch 1 taken 130171014 times.
131670140 if(!jinx_check) //If not already a jinx-immune-only check...
2278 {
2279 //And the player IS jinxed...
2280
3/4
✓ Branch 0 taken 129154633 times.
✓ Branch 1 taken 1016381 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 129154633 times.
130171014 if(HeroSwordClk() || HeroItemClk())
2281 {
2282 //Then do a jinx-immune-only check here
2283 1016381 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2284 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2285 //Should NOT need a compat rule, as this should always return -1 in old quests.
2286
2/2
✓ Branch 0 taken 30851 times.
✓ Branch 1 taken 985530 times.
1016381 if(ret2 > -1) return ret2;
2287 985530 }
2288 130140163 }
2289 131639289 return ret;
2290 131670140 }
2291 866055 int32_t current_item_power(int32_t itemtype)
2292 {
2293 866055 int32_t result = current_item_id(itemtype,true);
2294
2/2
✓ Branch 0 taken 825980 times.
✓ Branch 1 taken 40075 times.
866055 return (result<0) ? 0 : itemsbuf[result].power;
2295 }
2296
2297 int32_t heart_container_id()
2298 {
2299 for(int32_t i=0; i<MAXITEMS; i++)
2300 {
2301 if(itemsbuf[i].family == itype_heartcontainer)
2302 {
2303 return i;
2304 }
2305 }
2306 return -1;
2307 }
2308
2309 240509 int32_t item_tile_mod()
2310 {
2311 240509 int32_t tile=0;
2312
2313
2/2
✓ Branch 0 taken 26831 times.
✓ Branch 1 taken 213678 times.
240509 if(game->get_bombs())
2314 {
2315 213678 int32_t itemid = current_item_id(itype_bomb,false);
2316
3/4
✓ Branch 0 taken 213309 times.
✓ Branch 1 taken 369 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 213309 times.
213678 if(itemid > -1 && checkbunny(itemid))
2317 213309 tile+=itemsbuf[itemid].ltm;
2318 213678 }
2319
2320
2/2
✓ Branch 0 taken 229715 times.
✓ Branch 1 taken 10794 times.
240509 if(game->get_sbombs())
2321 {
2322 10794 int32_t itemid = current_item_id(itype_sbomb,false);
2323
3/4
✓ Branch 0 taken 4127 times.
✓ Branch 1 taken 6667 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4127 times.
10794 if(itemid > -1 && checkbunny(itemid))
2324 4127 tile+=itemsbuf[itemid].ltm;
2325 10794 }
2326
2327
2/2
✓ Branch 0 taken 235751 times.
✓ Branch 1 taken 4758 times.
240509 if(current_item(itype_clock))
2328 {
2329 4758 int32_t itemid =
2330
1/2
✓ Branch 0 taken 4758 times.
✗ Branch 1 not taken.
4758 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2331 ? iClock
2332 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2333
2/4
✓ Branch 0 taken 4758 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4758 times.
4758 if(itemid > -1 && checkbunny(itemid))
2334 4758 tile+=itemsbuf[itemid].ltm;
2335 4758 }
2336
2337
2/2
✓ Branch 0 taken 105406 times.
✓ Branch 1 taken 135103 times.
240509 if(current_item(itype_key))
2338 {
2339 135103 int32_t itemid =
2340
1/2
✓ Branch 0 taken 135103 times.
✗ Branch 1 not taken.
135103 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2341 ? iKey
2342 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2343
2/4
✓ Branch 0 taken 135103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 135103 times.
135103 if(itemid > -1 && checkbunny(itemid))
2344 135103 tile+=itemsbuf[itemid].ltm;
2345 135103 }
2346
2347
1/2
✓ Branch 0 taken 240509 times.
✗ Branch 1 not taken.
240509 if(current_item(itype_lkey))
2348 {
2349 int32_t itemid =
2350 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2351 ? iLevelKey
2352 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2353 if(itemid > -1 && checkbunny(itemid))
2354 tile+=itemsbuf[itemid].ltm;
2355 }
2356
2357
2/2
✓ Branch 0 taken 118704 times.
✓ Branch 1 taken 121805 times.
240509 if(current_item(itype_map))
2358 {
2359 121805 int32_t itemid =
2360
1/2
✓ Branch 0 taken 121805 times.
✗ Branch 1 not taken.
121805 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2361 ? iMap
2362 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2363
2/4
✓ Branch 0 taken 121805 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 121805 times.
121805 if(itemid > -1 && checkbunny(itemid))
2364 121805 tile+=itemsbuf[itemid].ltm;
2365 121805 }
2366
2367
2/2
✓ Branch 0 taken 71541 times.
✓ Branch 1 taken 168968 times.
240509 if(current_item(itype_compass))
2368 {
2369 168968 int32_t itemid =
2370
1/2
✓ Branch 0 taken 168968 times.
✗ Branch 1 not taken.
168968 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2371 ? iCompass
2372 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2373
2/4
✓ Branch 0 taken 168968 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 168968 times.
168968 if(itemid > -1 && checkbunny(itemid))
2374 168968 tile+=itemsbuf[itemid].ltm;
2375 168968 }
2376
2377
1/2
✓ Branch 0 taken 240509 times.
✗ Branch 1 not taken.
240509 if(current_item(itype_bosskey))
2378 {
2379 int32_t itemid =
2380 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2381 ? iBossKey
2382 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2383 if(itemid > -1 && checkbunny(itemid))
2384 tile+=itemsbuf[itemid].ltm;
2385 }
2386
2387
1/2
✓ Branch 0 taken 240509 times.
✗ Branch 1 not taken.
240509 if(current_item(itype_magiccontainer))
2388 {
2389 int32_t itemid =
2390 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2391 ? iMagicC
2392 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2393 if(itemid > -1 && checkbunny(itemid))
2394 tile+=itemsbuf[itemid].ltm;
2395 }
2396
2397
2/2
✓ Branch 0 taken 52161 times.
✓ Branch 1 taken 188348 times.
240509 if(current_item(itype_triforcepiece))
2398 {
2399 188348 int32_t itemid =
2400
1/2
✓ Branch 0 taken 188348 times.
✗ Branch 1 not taken.
188348 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2401 ? iTriforce
2402 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2403
2/4
✓ Branch 0 taken 188348 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 188348 times.
188348 if(itemid > -1 && checkbunny(itemid))
2404 188348 tile+=itemsbuf[itemid].ltm;
2405 188348 }
2406
2407
2/2
✓ Branch 0 taken 240509 times.
✓ Branch 1 taken 123140608 times.
123381117 for(int32_t i=0; i<itype_max; i++)
2408 {
2409
2/2
✓ Branch 0 taken 117653504 times.
✓ Branch 1 taken 5487104 times.
123140608 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2410 {
2411
2/2
✓ Branch 0 taken 107170 times.
✓ Branch 1 taken 5379934 times.
5487104 switch(i)
2412 {
2413 case itype_bomb:
2414 case itype_sbomb:
2415 case itype_clock:
2416 case itype_key:
2417 case itype_lkey:
2418 case itype_map:
2419 case itype_compass:
2420 case itype_bosskey:
2421 case itype_magiccontainer:
2422 case itype_triforcepiece:
2423 107170 continue; //already handled
2424 }
2425 5379934 }
2426 123033438 int32_t itemid = current_item_id(i,false);
2427
2/2
✓ Branch 0 taken 122792929 times.
✓ Branch 1 taken 240509 times.
123033438 if(i == itype_shield)
2428 240509 itemid = getCurrentShield(false);
2429
2430
3/4
✓ Branch 0 taken 1944370 times.
✓ Branch 1 taken 121089068 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1944370 times.
123033438 if(itemid < 0 || !checkbunny(itemid))
2431 121089068 continue;
2432
2433 1944370 itemdata const& itm = itemsbuf[itemid];
2434
2435
2/2
✓ Branch 0 taken 1703861 times.
✓ Branch 1 taken 240509 times.
1944370 switch(itm.family)
2436 {
2437 case itype_shield:
2438
1/2
✓ Branch 0 taken 240509 times.
✗ Branch 1 not taken.
240509 if(itm.flags & ITEM_FLAG9) //active shield
2439 {
2440 if(!usingActiveShield(itemid))
2441 {
2442 tile+=itm.misc6; //'Inactive PTM'
2443 continue;
2444 }
2445 }
2446 240509 break;
2447 }
2448
2449 1944370 tile+=itm.ltm;
2450 1944370 }
2451
2452 240509 return tile;
2453 }
2454
2455 240509 int32_t bunny_tile_mod()
2456 {
2457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240509 times.
240509 if(Hero.BunnyClock())
2458 {
2459 return game->get_bunny_ltm();
2460 }
2461 240509 return 0;
2462 240509 }
2463
2464 // Hints are drawn on a separate layer to combo reveals.
2465 void draw_lens_under(BITMAP *dest, bool layer)
2466 {
2467 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2468 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2469 //Lens flag 3: Don't show armos/chest/dive items
2470 //Lens flag 4: Show Raft Paths
2471 //Lens flag 5: Show Invisible Enemies
2472 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2473
2474 int32_t strike_hint_table[11]=
2475 {
2476 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2477 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2478 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2479 };
2480
2481 // int32_t page = tmpscr->cpage;
2482 {
2483 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2484 // int32_t temptimer=0;
2485 int32_t tempitem, tempweapon=0;
2486 strike_hint=strike_hint_table[strike_hint_counter];
2487
2488 if(strike_hint_timer>32)
2489 {
2490 strike_hint_timer=0;
2491 strike_hint_counter=((strike_hint_counter+1)%11);
2492 }
2493
2494 ++strike_hint_timer;
2495
2496 for(int32_t i=0; i<176; i++)
2497 {
2498 int32_t x = (i & 15) << 4;
2499 int32_t y = (i & 0xF0) + playing_field_offset;
2500 int32_t tempitemx=-16, tempitemy=-16;
2501 int32_t tempweaponx=-16, tempweapony=-16;
2502
2503 for(int32_t iter=0; iter<2; ++iter)
2504 {
2505 int32_t checkflag=0;
2506
2507 if(iter==0)
2508 {
2509 checkflag=combobuf[tmpscr->data[i]].flag;
2510 }
2511 else
2512 {
2513 checkflag=tmpscr->sflag[i];
2514 }
2515
2516 if(checkflag==mfSTRIKE)
2517 {
2518 if(!hints)
2519 {
2520 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2521 }
2522 else
2523 {
2524 checkflag = strike_hint;
2525 }
2526 }
2527
2528 switch(checkflag)
2529 {
2530 case 0:
2531 case mfZELDA:
2532 case mfPUSHED:
2533 case mfENEMY0:
2534 case mfENEMY1:
2535 case mfENEMY2:
2536 case mfENEMY3:
2537 case mfENEMY4:
2538 case mfENEMY5:
2539 case mfENEMY6:
2540 case mfENEMY7:
2541 case mfENEMY8:
2542 case mfENEMY9:
2543 case mfSINGLE:
2544 case mfSINGLE16:
2545 case mfNOENEMY:
2546 case mfTRAP_H:
2547 case mfTRAP_V:
2548 case mfTRAP_4:
2549 case mfTRAP_LR:
2550 case mfTRAP_UD:
2551 case mfNOGROUNDENEMY:
2552 case mfNOBLOCKS:
2553 case mfSCRIPT1:
2554 case mfSCRIPT2:
2555 case mfSCRIPT3:
2556 case mfSCRIPT4:
2557 case mfSCRIPT5:
2558 case mfSCRIPT6:
2559 case mfSCRIPT7:
2560 case mfSCRIPT8:
2561 case mfSCRIPT9:
2562 case mfSCRIPT10:
2563 case mfSCRIPT11:
2564 case mfSCRIPT12:
2565 case mfSCRIPT13:
2566 case mfSCRIPT14:
2567 case mfSCRIPT15:
2568 case mfSCRIPT16:
2569 case mfSCRIPT17:
2570 case mfSCRIPT18:
2571 case mfSCRIPT19:
2572 case mfSCRIPT20:
2573 case mfPITHOLE:
2574 case mfPITFALLFLOOR:
2575 case mfLAVA:
2576 case mfICE:
2577 case mfICEDAMAGE:
2578 case mfDAMAGE1:
2579 case mfDAMAGE2:
2580 case mfDAMAGE4:
2581 case mfDAMAGE8:
2582 case mfDAMAGE16:
2583 case mfDAMAGE32:
2584 case mfFREEZEALL:
2585 case mfFREZEALLANSFFCS:
2586 case mfFREEZEFFCSOLY:
2587 case mfSCRITPTW1TRIG:
2588 case mfSCRITPTW2TRIG:
2589 case mfSCRITPTW3TRIG:
2590 case mfSCRITPTW4TRIG:
2591 case mfSCRITPTW5TRIG:
2592 case mfSCRITPTW6TRIG:
2593 case mfSCRITPTW7TRIG:
2594 case mfSCRITPTW8TRIG:
2595 case mfSCRITPTW9TRIG:
2596 case mfSCRITPTW10TRIG:
2597 case mfTROWEL:
2598 case mfTROWELNEXT:
2599 case mfTROWELSPECIALITEM:
2600 case mfSLASHPOT:
2601 case mfLIFTPOT:
2602 case mfLIFTORSLASH:
2603 case mfLIFTROCK:
2604 case mfLIFTROCKHEAVY:
2605 case mfDROPITEM:
2606 case mfSPECIALITEM:
2607 case mfDROPKEY:
2608 case mfDROPLKEY:
2609 case mfDROPCOMPASS:
2610 case mfDROPMAP:
2611 case mfDROPBOSSKEY:
2612 case mfSPAWNNPC:
2613 case mfSWITCHHOOK:
2614 case mfSIDEVIEWLADDER:
2615 case mfSIDEVIEWPLATFORM:
2616 case mfNOENEMYSPAWN:
2617 case mfENEMYALL:
2618 case mfNOMIRROR:
2619 case mfUNSAFEGROUND:
2620 case mf168:
2621 case mf169:
2622 case mf170:
2623 case mf171:
2624 case mf172:
2625 case mf173:
2626 case mf174:
2627 case mf175:
2628 case mf176:
2629 case mf177:
2630 case mf178:
2631 case mf179:
2632 case mf180:
2633 case mf181:
2634 case mf182:
2635 case mf183:
2636 case mf184:
2637 case mf185:
2638 case mf186:
2639 case mf187:
2640 case mf188:
2641 case mf189:
2642 case mf190:
2643 case mf191:
2644 case mf192:
2645 case mf193:
2646 case mf194:
2647 case mf195:
2648 case mf196:
2649 case mf197:
2650 case mf198:
2651 case mf199:
2652 case mf200:
2653 case mf201:
2654 case mf202:
2655 case mf203:
2656 case mf204:
2657 case mf205:
2658 case mf206:
2659 case mf207:
2660 case mf208:
2661 case mf209:
2662 case mf210:
2663 case mf211:
2664 case mf212:
2665 case mf213:
2666 case mf214:
2667 case mf215:
2668 case mf216:
2669 case mf217:
2670 case mf218:
2671 case mf219:
2672 case mf220:
2673 case mf221:
2674 case mf222:
2675 case mf223:
2676 case mf224:
2677 case mf225:
2678 case mf226:
2679 case mf227:
2680 case mf228:
2681 case mf229:
2682 case mf230:
2683 case mf231:
2684 case mf232:
2685 case mf233:
2686 case mf234:
2687 case mf235:
2688 case mf236:
2689 case mf237:
2690 case mf238:
2691 case mf239:
2692 case mf240:
2693 case mf241:
2694 case mf242:
2695 case mf243:
2696 case mf244:
2697 case mf245:
2698 case mf246:
2699 case mf247:
2700 case mf248:
2701 case mf249:
2702 case mf250:
2703 case mf251:
2704 case mf252:
2705 case mf253:
2706 case mf254:
2707 case mfEXTENDED:
2708 break;
2709
2710 case mfPUSHUD:
2711 case mfPUSHLR:
2712 case mfPUSH4:
2713 case mfPUSHU:
2714 case mfPUSHD:
2715 case mfPUSHL:
2716 case mfPUSHR:
2717 case mfPUSHUDNS:
2718 case mfPUSHLRNS:
2719 case mfPUSH4NS:
2720 case mfPUSHUNS:
2721 case mfPUSHDNS:
2722 case mfPUSHLNS:
2723 case mfPUSHRNS:
2724 case mfPUSHUDINS:
2725 case mfPUSHLRINS:
2726 case mfPUSH4INS:
2727 case mfPUSHUINS:
2728 case mfPUSHDINS:
2729 case mfPUSHLINS:
2730 case mfPUSHRINS:
2731 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2732 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2733 {
2734 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2735 }
2736
2737 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2738 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2739 {
2740 if(hints)
2741 {
2742 switch(combobuf[tmpscr->data[i]].type)
2743 {
2744 case cPUSH_HEAVY:
2745 case cPUSH_HW:
2746 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2747 tempitemx=x, tempitemy=y;
2748
2749 if(tempitem>-1)
2750 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2751
2752 break;
2753
2754 case cPUSH_HEAVY2:
2755 case cPUSH_HW2:
2756 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2757 tempitemx=x, tempitemy=y;
2758
2759 if(tempitem>-1)
2760 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2761
2762 break;
2763 }
2764 }
2765 }
2766
2767 break;
2768
2769 case mfWHISTLE:
2770 if(hints)
2771 {
2772 tempitem=getItemID(itemsbuf,itype_whistle,1);
2773
2774 if(tempitem<0) break;
2775
2776 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2777 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2778 {
2779 tempitemx=x;
2780 tempitemy=y;
2781 }
2782
2783 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2784 }
2785
2786 break;
2787
2788 //Why is this here?
2789 case mfFAIRY:
2790 case mfMAGICFAIRY:
2791 case mfALLFAIRY:
2792 if(hints)
2793 {
2794 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2795
2796 if(tempitem < 0) break;
2797
2798 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2799 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2800 {
2801 tempitemx=x;
2802 tempitemy=y;
2803 }
2804
2805 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2806 }
2807
2808 break;
2809
2810 case mfBCANDLE:
2811 if(!hints)
2812 {
2813 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2814 }
2815 else
2816 {
2817 tempitem=getItemID(itemsbuf,itype_candle,1);
2818
2819 if(tempitem<0) break;
2820
2821 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2822 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2823 {
2824 tempitemx=x;
2825 tempitemy=y;
2826 }
2827
2828 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2829 }
2830
2831 break;
2832
2833 case mfRCANDLE:
2834 if(!hints)
2835 {
2836 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2837 }
2838 else
2839 {
2840 tempitem=getItemID(itemsbuf,itype_candle,2);
2841
2842 if(tempitem<0) break;
2843
2844 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2845 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2846 {
2847 tempitemx=x;
2848 tempitemy=y;
2849 }
2850
2851 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2852 }
2853
2854 break;
2855
2856 case mfWANDFIRE:
2857 if(!hints)
2858 {
2859 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2860 }
2861 else
2862 {
2863 tempitem=getItemID(itemsbuf,itype_wand,1);
2864
2865 if(tempitem<0) break;
2866
2867 tempweapon=wFire;
2868
2869 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2870 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2871 {
2872 tempitemx=x;
2873 tempitemy=y;
2874 }
2875 else
2876 {
2877 tempweaponx=x;
2878 tempweapony=y;
2879 }
2880
2881 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2882 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2883 }
2884
2885 break;
2886
2887 case mfDINSFIRE:
2888 if(!hints)
2889 {
2890 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2891 }
2892 else
2893 {
2894 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2895
2896 if(tempitem<0) break;
2897
2898 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2899 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2900 {
2901 tempitemx=x;
2902 tempitemy=y;
2903 }
2904
2905 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2906 }
2907
2908 break;
2909
2910 case mfARROW:
2911 if(!hints)
2912 {
2913 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2914 }
2915 else
2916 {
2917 tempitem=getItemID(itemsbuf,itype_arrow,1);
2918
2919 if(tempitem<0) break;
2920
2921 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2922 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2923 {
2924 tempitemx=x;
2925 tempitemy=y;
2926 }
2927
2928 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2929 }
2930
2931 break;
2932
2933 case mfSARROW:
2934 if(!hints)
2935 {
2936 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2937 }
2938 else
2939 {
2940 tempitem=getItemID(itemsbuf,itype_arrow,2);
2941
2942 if(tempitem<0) break;
2943
2944 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2945 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2946 {
2947 tempitemx=x;
2948 tempitemy=y;
2949 }
2950
2951 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2952 }
2953
2954 break;
2955
2956 case mfGARROW:
2957 if(!hints)
2958 {
2959 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2960 }
2961 else
2962 {
2963 tempitem=getItemID(itemsbuf,itype_arrow,3);
2964
2965 if(tempitem<0) break;
2966
2967 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2968 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2969 {
2970 tempitemx=x;
2971 tempitemy=y;
2972 }
2973
2974 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2975 }
2976
2977 break;
2978
2979 case mfBOMB:
2980 if(!hints)
2981 {
2982 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2983 }
2984 else
2985 {
2986 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2987 tempweapon = wLitBomb;
2988
2989 //if (tempitem<0) break;
2990 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2991 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2992 {
2993 tempweaponx=x;
2994 tempweapony=y;
2995 }
2996
2997 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2998 }
2999
3000 break;
3001
3002 case mfSBOMB:
3003 if(!hints)
3004 {
3005 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
3006 }
3007 else
3008 {
3009 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
3010 //if (tempitem<0) break;
3011 tempweapon = wLitSBomb;
3012
3013 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3014 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3015 {
3016 tempweaponx=x;
3017 tempweapony=y;
3018 }
3019
3020 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3021 }
3022
3023 break;
3024
3025 case mfARMOS_SECRET:
3026 if(!hints)
3027 {
3028 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3029 }
3030 break;
3031
3032 case mfBRANG:
3033 if(!hints)
3034 {
3035 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
3036 }
3037 else
3038 {
3039 tempitem=getItemID(itemsbuf,itype_brang,1);
3040
3041 if(tempitem<0) break;
3042
3043 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3044 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3045 {
3046 tempitemx=x;
3047 tempitemy=y;
3048 }
3049
3050 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3051 }
3052
3053 break;
3054
3055 case mfMBRANG:
3056 if(!hints)
3057 {
3058 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3059 }
3060 else
3061 {
3062 tempitem=getItemID(itemsbuf,itype_brang,2);
3063
3064 if(tempitem<0) break;
3065
3066 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3067 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3068 {
3069 tempitemx=x;
3070 tempitemy=y;
3071 }
3072
3073 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3074 }
3075
3076 break;
3077
3078 case mfFBRANG:
3079 if(!hints)
3080 {
3081 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3082 }
3083 else
3084 {
3085 tempitem=getItemID(itemsbuf,itype_brang,3);
3086
3087 if(tempitem<0) break;
3088
3089 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3090 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3091 {
3092 tempitemx=x;
3093 tempitemy=y;
3094 }
3095
3096 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3097 }
3098
3099 break;
3100
3101 case mfWANDMAGIC:
3102 if(!hints)
3103 {
3104 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3105 }
3106 else
3107 {
3108 tempitem=getItemID(itemsbuf,itype_wand,1);
3109
3110 if(tempitem<0) break;
3111
3112 tempweapon=itemsbuf[tempitem].wpn3;
3113
3114 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3115 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3116 {
3117 tempitemx=x;
3118 tempitemy=y;
3119 }
3120 else
3121 {
3122 tempweaponx=x;
3123 tempweapony=y;
3124 --lens_hint_weapon[wMagic][4];
3125
3126 if(lens_hint_weapon[wMagic][4]<-8)
3127 {
3128 lens_hint_weapon[wMagic][4]=8;
3129 }
3130 }
3131
3132 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3133 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3134 }
3135
3136 break;
3137
3138 case mfREFMAGIC:
3139 if(!hints)
3140 {
3141 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3142 }
3143 else
3144 {
3145 tempitem=getItemID(itemsbuf,itype_shield,3);
3146
3147 if(tempitem<0) break;
3148
3149 tempweapon=ewMagic;
3150
3151 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3152 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3153 {
3154 tempitemx=x;
3155 tempitemy=y;
3156 }
3157 else
3158 {
3159 tempweaponx=x;
3160 tempweapony=y;
3161
3162 if(lens_hint_weapon[ewMagic][2]==up)
3163 {
3164 --lens_hint_weapon[ewMagic][4];
3165 }
3166 else
3167 {
3168 ++lens_hint_weapon[ewMagic][4];
3169 }
3170
3171 if(lens_hint_weapon[ewMagic][4]>8)
3172 {
3173 lens_hint_weapon[ewMagic][2]=up;
3174 }
3175
3176 if(lens_hint_weapon[ewMagic][4]<=0)
3177 {
3178 lens_hint_weapon[ewMagic][2]=down;
3179 }
3180 }
3181
3182 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3183 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3184 }
3185
3186 break;
3187
3188 case mfREFFIREBALL:
3189 if(!hints)
3190 {
3191 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3192 }
3193 else
3194 {
3195 tempitem=getItemID(itemsbuf,itype_shield,3);
3196
3197 if(tempitem<0) break;
3198
3199 tempweapon=ewFireball;
3200
3201 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3202 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3203 {
3204 tempitemx=x;
3205 tempitemy=y;
3206 tempweaponx=x;
3207 tempweapony=y;
3208 ++lens_hint_weapon[ewFireball][3];
3209
3210 if(lens_hint_weapon[ewFireball][3]>8)
3211 {
3212 lens_hint_weapon[ewFireball][3]=-8;
3213 lens_hint_weapon[ewFireball][4]=8;
3214 }
3215
3216 if(lens_hint_weapon[ewFireball][3]>0)
3217 {
3218 ++lens_hint_weapon[ewFireball][4];
3219 }
3220 else
3221 {
3222 --lens_hint_weapon[ewFireball][4];
3223 }
3224 }
3225
3226 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3227 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3228 }
3229
3230 break;
3231
3232 case mfSWORD:
3233 if(!hints)
3234 {
3235 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3236 }
3237 else
3238 {
3239 tempitem=getItemID(itemsbuf,itype_sword,1);
3240
3241 if(tempitem<0) break;
3242
3243 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3244 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3245 {
3246 tempitemx=x;
3247 tempitemy=y;
3248 }
3249
3250 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3251 }
3252
3253 break;
3254
3255 case mfWSWORD:
3256 if(!hints)
3257 {
3258 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3259 }
3260 else
3261 {
3262 tempitem=getItemID(itemsbuf,itype_sword,2);
3263
3264 if(tempitem<0) break;
3265
3266 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3267 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3268 {
3269 tempitemx=x;
3270 tempitemy=y;
3271 }
3272
3273 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3274 }
3275
3276 break;
3277
3278 case mfMSWORD:
3279 if(!hints)
3280 {
3281 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3282 }
3283 else
3284 {
3285 tempitem=getItemID(itemsbuf,itype_sword,3);
3286
3287 if(tempitem<0) break;
3288
3289 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3290 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3291 {
3292 tempitemx=x;
3293 tempitemy=y;
3294 }
3295
3296 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3297 }
3298
3299 break;
3300
3301 case mfXSWORD:
3302 if(!hints)
3303 {
3304 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3305 }
3306 else
3307 {
3308 tempitem=getItemID(itemsbuf,itype_sword,4);
3309
3310 if(tempitem<0) break;
3311
3312 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3313 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3314 {
3315 tempitemx=x;
3316 tempitemy=y;
3317 }
3318
3319 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3320 }
3321
3322 break;
3323
3324 case mfSWORDBEAM:
3325 if(!hints)
3326 {
3327 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3328 }
3329 else
3330 {
3331 tempitem=getItemID(itemsbuf,itype_sword,1);
3332
3333 if(tempitem<0) break;
3334
3335 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3336 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3337 {
3338 tempitemx=x;
3339 tempitemy=y;
3340 }
3341
3342 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3343 }
3344
3345 break;
3346
3347 case mfWSWORDBEAM:
3348 if(!hints)
3349 {
3350 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3351 }
3352 else
3353 {
3354 tempitem=getItemID(itemsbuf,itype_sword,2);
3355
3356 if(tempitem<0) break;
3357
3358 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3359 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3360 {
3361 tempitemx=x;
3362 tempitemy=y;
3363 }
3364
3365 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3366 }
3367
3368 break;
3369
3370 case mfMSWORDBEAM:
3371 if(!hints)
3372 {
3373 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3374 }
3375 else
3376 {
3377 tempitem=getItemID(itemsbuf,itype_sword,3);
3378
3379 if(tempitem<0) break;
3380
3381 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3382 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3383 {
3384 tempitemx=x;
3385 tempitemy=y;
3386 }
3387
3388 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3389 }
3390
3391 break;
3392
3393 case mfXSWORDBEAM:
3394 if(!hints)
3395 {
3396 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3397 }
3398 else
3399 {
3400 tempitem=getItemID(itemsbuf,itype_sword,4);
3401
3402 if(tempitem<0) break;
3403
3404 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3405 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3406 {
3407 tempitemx=x;
3408 tempitemy=y;
3409 }
3410
3411 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3412 }
3413
3414 break;
3415
3416 case mfHOOKSHOT:
3417 if(!hints)
3418 {
3419 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3420 }
3421 else
3422 {
3423 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3424
3425 if(tempitem<0) break;
3426
3427 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3428 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3429 {
3430 tempitemx=x;
3431 tempitemy=y;
3432 }
3433
3434 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3435 }
3436
3437 break;
3438
3439 case mfWAND:
3440 if(!hints)
3441 {
3442 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3443 }
3444 else
3445 {
3446 tempitem=getItemID(itemsbuf,itype_wand,1);
3447
3448 if(tempitem<0) break;
3449
3450 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3451 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3452 {
3453 tempitemx=x;
3454 tempitemy=y;
3455 }
3456
3457 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3458 }
3459
3460 break;
3461
3462 case mfHAMMER:
3463 if(!hints)
3464 {
3465 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3466 }
3467 else
3468 {
3469 tempitem=getItemID(itemsbuf,itype_hammer,1);
3470
3471 if(tempitem<0) break;
3472
3473 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3474 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3475 {
3476 tempitemx=x;
3477 tempitemy=y;
3478 }
3479
3480 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3481 }
3482
3483 break;
3484
3485 case mfARMOS_ITEM:
3486 case mfDIVE_ITEM:
3487 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3488 {
3489 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3490 }
3491 break;
3492
3493 case 16:
3494 case 17:
3495 case 18:
3496 case 19:
3497 case 20:
3498 case 21:
3499 case 22:
3500 case 23:
3501 case 24:
3502 case 25:
3503 case 26:
3504 case 27:
3505 case 28:
3506 case 29:
3507 case 30:
3508 case 31:
3509 if(!hints)
3510 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3511 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3512
3513 break;
3514 case mfSECRETSNEXT:
3515 if(!hints)
3516 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3517 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3518
3519 break;
3520
3521 case mfSTRIKE:
3522 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3523 {
3524 goto special;
3525 }
3526 else
3527 {
3528 break;
3529 }
3530
3531 default: goto special;
3532
3533 special:
3534 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3535 {
3536 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3537 {
3538 rectfill(dest,x,y,x+15,y+15,WHITE);
3539 }
3540 }
3541
3542 break;
3543 }
3544 }
3545 }
3546
3547 if(layer)
3548 {
3549 if(tmpscr->door[0]==dWALK)
3550 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3551
3552 if(tmpscr->door[1]==dWALK)
3553 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3554
3555 if(tmpscr->door[2]==dWALK)
3556 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3557
3558 if(tmpscr->door[3]==dWALK)
3559 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3560
3561 if(tmpscr->door[0]==dBOMB)
3562 {
3563 showbombeddoor(dest, 0);
3564 }
3565
3566 if(tmpscr->door[1]==dBOMB)
3567 {
3568 showbombeddoor(dest, 1);
3569 }
3570
3571 if(tmpscr->door[2]==dBOMB)
3572 {
3573 showbombeddoor(dest, 2);
3574 }
3575
3576 if(tmpscr->door[3]==dBOMB)
3577 {
3578 showbombeddoor(dest, 3);
3579 }
3580 }
3581
3582 if(tmpscr->stairx + tmpscr->stairy)
3583 {
3584 if(!hints)
3585 {
3586 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3587 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3588 }
3589 else
3590 {
3591 if(tmpscr->flags&fWHISTLE)
3592 {
3593 tempitem=getItemID(itemsbuf,itype_whistle,1);
3594 int32_t tempitemx=-16;
3595 int32_t tempitemy=-16;
3596
3597 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3598 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3599 {
3600 tempitemx=tmpscr->stairx;
3601 tempitemy=tmpscr->stairy+playing_field_offset;
3602 }
3603
3604 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3605 }
3606 }
3607 }
3608 }
3609 }
3610
3611 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3612
3613 void draw_lens_over()
3614 {
3615 // Oh, what the heck.
3616 static BITMAP *lens_scr = NULL;
3617 static int32_t last_width = -1;
3618 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3619
3620 // Only redraw the circle if the size has changed
3621 if(width != last_width)
3622 {
3623 if(lens_scr == NULL)
3624 {
3625 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3626 }
3627
3628 clear_to_color(lens_scr, BLACK);
3629 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3630 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3631 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3632 last_width=width;
3633 }
3634
3635 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3636 }
3637
3638 //----------------------------------------------------------------
3639
3640 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3641 {
3642 //recreating a big bitmap every frame is highly sluggish.
3643 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3644 clear_to_color(wavebuf, BLACK);
3645 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3646
3647 int32_t ofs;
3648 // int32_t amplitude=8;
3649 // int32_t wavelength=4;
3650 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3651 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3652 int32_t amp2=168;
3653 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3654 int32_t i=frame%amp2;
3655
3656 for(int32_t j=0; j<168; j++)
3657 {
3658 if(j&1 && interpol)
3659 {
3660 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3661 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3662 }
3663 else
3664 {
3665 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3666 }
3667
3668 if(ofs)
3669 {
3670 for(int32_t k=0; k<256; k++)
3671 {
3672 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3673 }
3674 }
3675 }
3676 }
3677
3678 void draw_fuzzy(int32_t fuzz)
3679 // draws from right half of scrollbuf to framebuf
3680 {
3681 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3682 byte *start, *si, *di;
3683
3684 if(fuzz<1)
3685 fuzz = 1;
3686
3687 xstep = 128%fuzz;
3688
3689 if(xstep > 0)
3690 xstep = fuzz-xstep;
3691
3692 ystep = 112%fuzz;
3693
3694 if(ystep > 0)
3695 ystep = fuzz-ystep;
3696
3697 firsty = 1;
3698
3699 for(y=0; y<224;)
3700 {
3701 start = &(scrollbuf->line[y][256]);
3702
3703 for(dy=0; dy<ystep && dy+y<224; dy++)
3704 {
3705 si = start;
3706 di = &(framebuf->line[y+dy][0]);
3707 i = xstep;
3708 firstx = 1;
3709
3710 for(dx=0; dx<256; dx++)
3711 {
3712 *(di++) = *si;
3713
3714 if(++i >= fuzz)
3715 {
3716 if(!firstx)
3717 si += fuzz;
3718 else
3719 {
3720 si += fuzz-xstep;
3721 firstx = 0;
3722 }
3723
3724 i = 0;
3725 }
3726 }
3727 }
3728
3729 if(!firsty)
3730 y += fuzz;
3731 else
3732 {
3733 y += ystep;
3734 ystep = fuzz;
3735 firsty = 0;
3736 }
3737 }
3738 }
3739
3740 435420 void updatescr(bool allowwavy)
3741 {
3742
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 435411 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✓ Branch 4 taken 9 times.
✗ Branch 5 not taken.
435420 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3743
4/6
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 435411 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 9 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 9 times.
435420 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3744
3745
1/2
✓ Branch 0 taken 435420 times.
✗ Branch 1 not taken.
435420 if(toogam)
3746 {
3747 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3748 }
3749
3750
1/2
✓ Branch 0 taken 435420 times.
✗ Branch 1 not taken.
435420 if(Showpal)
3751 dump_pal(framebuf);
3752
3753
2/2
✓ Branch 0 taken 431132 times.
✓ Branch 1 taken 4288 times.
435420 if(!Playing)
3754 4288 black_opening_count=0;
3755
3756
2/2
✓ Branch 0 taken 433440 times.
✓ Branch 1 taken 1980 times.
435420 if(black_opening_count<0) //shape is opening up
3757 {
3758 1980 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3759
3760
2/4
✓ Branch 0 taken 1980 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1980 times.
1980 if(Advance||(!Paused))
3761 {
3762 1980 ++black_opening_count;
3763 1980 }
3764 1980 }
3765
2/2
✓ Branch 0 taken 432912 times.
✓ Branch 1 taken 528 times.
433440 else if(black_opening_count>0) //shape is closing
3766 {
3767 528 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3768
3769
2/4
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528 times.
528 if(Advance||(!Paused))
3770 {
3771 528 --black_opening_count;
3772 528 }
3773 528 }
3774
3775
3/4
✓ Branch 0 taken 432950 times.
✓ Branch 1 taken 2470 times.
✓ Branch 2 taken 432950 times.
✗ Branch 3 not taken.
435420 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3776 {
3777 black_opening_shape = bosCIRCLE;
3778 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3779 refreshTints();
3780 refreshpal=true;
3781 }
3782
3783
2/2
✓ Branch 0 taken 429432 times.
✓ Branch 1 taken 5988 times.
435420 if(refreshpal)
3784 {
3785 5988 refreshpal=false;
3786 5988 RAMpal[253] = _RGB(0,0,0);
3787 5988 RAMpal[254] = _RGB(63,63,63);
3788 5988 hw_palette = &RAMpal;
3789 5988 update_hw_pal = true;
3790
3791 5988 create_rgb_table(&rgb_table, RAMpal, NULL);
3792 5988 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3793 5988 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3794
3795
2/2
✓ Branch 0 taken 1532928 times.
✓ Branch 1 taken 5988 times.
1538916 for(int32_t q=0; q<PAL_SIZE; q++)
3796 {
3797 1532928 trans_table2.data[0][q] = q;
3798 1532928 trans_table2.data[q][q] = q;
3799 1532928 }
3800 5988 }
3801
3802 435420 bool clearwavy = (wavy <= 0);
3803
3804
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435420 times.
435420 if(wavy <= 0)
3805 {
3806 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3807 435420 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3808 435420 }
3809
3810 435420 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3811
3812
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 435420 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
435420 if(wavy && Playing && allowwavy)
3813 {
3814 draw_wavy(framebuf, wavybuf, wavy,false);
3815 }
3816
3817
1/2
✓ Branch 0 taken 435420 times.
✗ Branch 1 not taken.
435420 if(clearwavy)
3818 435420 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3819 else if(Playing && !Paused)
3820 wavy--; // Wavy was set by a script. Decrement it.
3821
3822
5/6
✓ Branch 0 taken 431132 times.
✓ Branch 1 taken 4288 times.
✓ Branch 2 taken 7514 times.
✓ Branch 3 taken 423618 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7514 times.
435420 if(Playing && msgpos && !screenscrolling)
3823 {
3824
1/2
✓ Branch 0 taken 7514 times.
✗ Branch 1 not taken.
7514 if(!(msg_bg_display_buf->clip))
3825 7514 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3826
1/2
✓ Branch 0 taken 7514 times.
✗ Branch 1 not taken.
7514 if(!(msg_portrait_display_buf->clip))
3827 7514 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3828
1/2
✓ Branch 0 taken 7514 times.
✗ Branch 1 not taken.
7514 if(!(msg_txt_display_buf->clip))
3829 7514 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3830 7514 }
3831
3832 /*
3833 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3834 {
3835 BITMAP* subBmp = 0;
3836 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3837 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3838 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3839 destroy_bitmap(subBmp);
3840 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3841 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3842 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3843 }
3844 */
3845
3846
1/2
✓ Branch 0 taken 435420 times.
✗ Branch 1 not taken.
435420 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3847
3848
1/2
✓ Branch 0 taken 435420 times.
✗ Branch 1 not taken.
435420 if(nosubscr)
3849 {
3850 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3851 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3852 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3853 }
3854
3855 //TODO: Optimize blit 'overcalls' -Gleeok
3856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435420 times.
435420 BITMAP *source = nosubscr ? panorama : wavybuf;
3857 435420 blit(source,framebuf,0,0,0,0,256,224);
3858
3859 435420 update_hw_screen();
3860 435420 }
3861
3862 //----------------------------------------------------------------
3863
3864 PALETTE sys_pal;
3865
3866 int32_t onGUISnapshot()
3867 {
3868 char buf[200];
3869 int32_t num=0;
3870 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3871 do
3872 {
3873 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3874 }
3875 while(num<99999 && exists(buf));
3876
3877 BITMAP *b = create_bitmap_ex(8,resx,resy);
3878
3879 if(b)
3880 {
3881 if(MenuOpen)
3882 {
3883 //Cannot load game's palette while GUI elements are in focus. -Z
3884 //If there is a way to do this, then I have missed it.
3885 /*
3886 game_pal();
3887 RAMpal[253] = _RGB(0,0,0);
3888 RAMpal[254] = _RGB(63,63,63);
3889 set_palette_range(RAMpal,0,255,false);
3890 memcpy(RAMpal, snappal, sizeof(snappal));
3891 create_rgb_table(&rgb_table, RAMpal, NULL);
3892 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3893 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3894
3895 for(int32_t q=0; q<PAL_SIZE; q++)
3896 {
3897 trans_table2.data[0][q] = q;
3898 trans_table2.data[q][q] = q;
3899 }
3900 */
3901 //ringcolor(false);
3902 //get_palette(RAMpal);
3903 blit(screen,b,0,0,0,0,resx,resy);
3904 //al_trace("Menu Open\n");
3905 //game_pal();
3906 //PALETTE temppal;
3907 //get_palette(temppal);
3908 //system_pal();
3909 save_bitmap(buf,b,sys_pal);
3910 //save_bitmap(buf,b,RAMpal);
3911 //save_bitmap(buf,b,snappal);
3912 }
3913 else
3914 {
3915 blit(screen,b,0,0,0,0,resx,resy);
3916 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3917 }
3918 destroy_bitmap(b);
3919 }
3920
3921 return D_O_K;
3922 }
3923
3924 int32_t onNonGUISnapshot()
3925 {
3926 PALETTE temppal;
3927 get_palette(temppal);
3928 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3929
3930 char buf[200];
3931 int32_t num=0;
3932
3933 do
3934 {
3935 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3936 }
3937 while(num<99999 && exists(buf));
3938
3939 BITMAP *panorama = create_bitmap_ex(8,256,168);
3940 /*
3941 PALETTE tempRAMpal;
3942 get_palette(tempRAMpal);
3943
3944 if(tmpscr->flags3&fNOSUBSCR)
3945 {
3946 clear_to_color(panorama,0);
3947 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3948 save_bitmap(buf,panorama,realpal?temppal:tempRAMpal);
3949 }
3950 else
3951 {
3952 save_bitmap(buf,framebuf,realpal?temppal:tempRAMpal);
3953 }
3954
3955 destroy_bitmap(panorama);
3956 return D_O_K;
3957 */
3958 if(tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3959 {
3960 clear_to_color(panorama,0);
3961 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3962 save_bitmap(buf,panorama,realpal?temppal:RAMpal);
3963 }
3964 else
3965 {
3966 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3967 }
3968
3969 destroy_bitmap(panorama);
3970 return D_O_K;
3971 }
3972
3973 int32_t onSnapshot()
3974 {
3975 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3976 {
3977 onGUISnapshot();
3978 }
3979 else
3980 {
3981 onNonGUISnapshot();
3982 }
3983
3984 return D_O_K;
3985 }
3986
3987 int32_t onSaveMapPic()
3988 {
3989 int32_t mapres2 = 0;
3990 char buf[200];
3991 int32_t num=0;
3992 mapscr tmpscr_b[2];
3993 mapscr tmpscr_c[6];
3994 BITMAP* _screen_draw_buffer = NULL;
3995 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3996 set_clip_state(_screen_draw_buffer,1);
3997
3998 for(int32_t i=0; i<6; ++i)
3999 {
4000 tmpscr_c[i] = tmpscr2[i];
4001 tmpscr2[i].zero_memory();
4002
4003 if(i>=2)
4004 {
4005 continue;
4006 }
4007
4008 tmpscr_b[i] = tmpscr[i];
4009 tmpscr[i].zero_memory();
4010 }
4011
4012 do
4013 {
4014 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
4015 }
4016 while(num<99999 && exists(buf));
4017
4018 BITMAP* mappic = NULL;
4019
4020
4021 bool done=false, redraw=true;
4022
4023 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
4024
4025 if(!mappic)
4026 {
4027 system_pal();
4028 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4029 game_pal();
4030 return D_O_K;;
4031 }
4032
4033 // draw the map
4034 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
4035
4036 for(int32_t y=0; y<8; y++)
4037 {
4038 for(int32_t x=0; x<16; x++)
4039 {
4040 if(!displayOnMap(x, y))
4041 {
4042 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4043 }
4044 else
4045 {
4046 int32_t s = (y<<4) + x;
4047 loadscr2(1,s,-1);
4048
4049 for(int32_t i=0; i<6; i++)
4050 {
4051 if(tmpscr[1].layermap[i]<=0)
4052 continue;
4053
4054 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4055 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4056 {
4057 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4058
4059 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4060 }
4061 }
4062
4063 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4064
4065 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4066
4067 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4068 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4069
4070 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4071
4072 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4073 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4074 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4075 {
4076 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4077 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4078 }
4079 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4080
4081 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4082
4083 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4084 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4085 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4086 {
4087 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4088 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4089 }
4090 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4091 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4092
4093 }
4094
4095 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4096 }
4097 }
4098
4099 for(int32_t i=0; i<6; ++i)
4100 {
4101 tmpscr2[i]=tmpscr_c[i];
4102
4103 if(i>=2)
4104 {
4105 continue;
4106 }
4107
4108 tmpscr[i]=tmpscr_b[i];
4109 }
4110
4111 save_bitmap(buf,mappic,RAMpal);
4112 destroy_bitmap(mappic);
4113 destroy_bitmap(_screen_draw_buffer);
4114 return D_O_K;
4115 }
4116
4117 /*
4118 int32_t onSaveMapPic()
4119 {
4120 BITMAP* mappic = NULL;
4121 BITMAP* _screen_draw_buffer = NULL;
4122 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4123 int32_t mapres2 = 0;
4124 char buf[20];
4125 int32_t num=0;
4126 set_clip_state(_screen_draw_buffer,1);
4127 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4128
4129 do
4130 {
4131 sprintf(buf, "zelda%03d.png", ++num);
4132 }
4133 while(num<999 && exists(buf));
4134
4135 // if(!mappic) {
4136 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4137
4138 if(!mappic)
4139 {
4140 system_pal();
4141 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4142 game_pal();
4143 return D_O_K;
4144 }
4145
4146 // }
4147
4148 int32_t layermap, layerscreen;
4149 int32_t x2=0;
4150
4151 // draw the map
4152 for(int32_t y=0; y<8; y++)
4153 {
4154 for(int32_t x=0; x<16; x++)
4155 {
4156 int32_t s = (y<<4) + x;
4157
4158 if(!displayOnMap(x, y))
4159 {
4160 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4161 }
4162 else
4163 {
4164 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4165 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4166
4167 for(int32_t k=0; k<4; k++)
4168 {
4169 if(k==2)
4170 {
4171 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4172 }
4173
4174 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4175
4176 if(layermap>-1)
4177 {
4178 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4179
4180 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4181 {
4182 for(int32_t i=0; i<176; i++)
4183 {
4184 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4185 }
4186 }
4187 else
4188 {
4189 for(int32_t i=0; i<176; i++)
4190 {
4191 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4192 }
4193 }
4194 }
4195 }
4196
4197 for(int32_t i=0; i<176; i++)
4198 {
4199 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4200 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4201 {
4202 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4203 }
4204 }
4205
4206 for(int32_t k=4; k<6; k++)
4207 {
4208 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4209
4210 if(layermap>-1)
4211 {
4212 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4213
4214 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4215 {
4216 for(int32_t i=0; i<176; i++)
4217 {
4218 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4219 }
4220 }
4221 else
4222 {
4223 for(int32_t i=0; i<176; i++)
4224 {
4225 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4226 }
4227 }
4228 }
4229 }
4230 }
4231
4232 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4233 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4234 }
4235
4236 }
4237
4238 save_bitmap(buf,mappic,RAMpal);
4239 destroy_bitmap(mappic);
4240 destroy_bitmap(_screen_draw_buffer);
4241 return D_O_K;
4242 }
4243 */
4244
4245 1 void f_Quit(int32_t type)
4246 {
4247
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(type==qQUIT && !Playing)
4248 return;
4249
4250 1 bool from_menu = is_sys_pal;
4251
4252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!from_menu)
4253 {
4254 1 music_pause();
4255 1 pause_all_sfx();
4256 1 }
4257 1 enter_sys_pal();
4258 1 clear_keybuf();
4259
4260 1 replay_poll();
4261
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (replay_is_replaying())
4262 1 replay_peek_quit();
4263
4264
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!replay_is_replaying())
4265 switch(type)
4266 {
4267 case qQUIT:
4268 onQuit();
4269 break;
4270
4271 case qRESET:
4272 onReset();
4273 break;
4274
4275 case qEXIT:
4276 onExit();
4277 break;
4278 }
4279
4280
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(Quit)
4281 {
4282 1 kill_sfx();
4283 1 music_stop();
4284 1 exit_sys_pal();
4285 1 update_hw_screen();
4286 1 }
4287 else
4288 {
4289 exit_sys_pal();
4290 if(!from_menu)
4291 {
4292 music_resume();
4293 resume_all_sfx();
4294 }
4295 }
4296
4297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!from_menu)
4298 1 show_mouse(NULL);
4299 1 eat_buttons();
4300
4301 1 zc_readrawkey(KEY_ESC);
4302
4303 1 zc_readrawkey(KEY_ENTER);
4304 1 }
4305
4306 //----------------------------------------------------------------
4307
4308 int32_t onNoWalls()
4309 {
4310 cheats_enqueue(Cheat::Walls);
4311 return D_O_K;
4312 }
4313
4314 int32_t onIgnoreSideview()
4315 {
4316 cheats_enqueue(Cheat::IgnoreSideView);
4317 return D_O_K;
4318 }
4319
4320 445220 int32_t input_idle(bool checkmouse)
4321 {
4322 static int32_t mx, my, mz, mb;
4323
4324
4/6
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61499 times.
✓ Branch 3 taken 383721 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 61499 times.
506719 if(keypressed() || zc_key_pressed() ||
4325
4/8
✓ Branch 0 taken 61499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61499 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 61499 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 61499 times.
✗ Branch 7 not taken.
61499 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4326 {
4327 383721 idle_count = 0;
4328
4329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 383721 times.
383721 if(active_count < MAX_ACTIVE)
4330 {
4331 383721 ++active_count;
4332 383721 }
4333 383721 }
4334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61499 times.
61499 else if(idle_count < MAX_IDLE)
4335 {
4336 61499 ++idle_count;
4337 61499 active_count = 0;
4338 61499 }
4339
4340 445220 mx = mouse_x;
4341 445220 my = mouse_y;
4342 445220 mz = mouse_z;
4343 445220 mb = mouse_b;
4344
4345 445220 return idle_count;
4346 }
4347
4348 int32_t onGoFast()
4349 {
4350 cheats_enqueue(Cheat::Fast);
4351 return D_O_K;
4352 }
4353
4354 int32_t onKillCheat()
4355 {
4356 cheats_enqueue(Cheat::Kill);
4357 return D_O_K;
4358 }
4359
4360 int32_t onShowLayer0()
4361 {
4362 show_layer_0 = !show_layer_0;
4363 return D_O_K;
4364 }
4365 int32_t onShowLayer1()
4366 {
4367 show_layer_1 = !show_layer_1;
4368 return D_O_K;
4369 }
4370 int32_t onShowLayer2()
4371 {
4372 show_layer_2 = !show_layer_2;
4373 return D_O_K;
4374 }
4375 int32_t onShowLayer3()
4376 {
4377 show_layer_3 = !show_layer_3;
4378 return D_O_K;
4379 }
4380 int32_t onShowLayer4()
4381 {
4382 show_layer_4 = !show_layer_4;
4383 return D_O_K;
4384 }
4385 int32_t onShowLayer5()
4386 {
4387 show_layer_5 = !show_layer_5;
4388 return D_O_K;
4389 }
4390 int32_t onShowLayer6()
4391 {
4392 show_layer_6 = !show_layer_6;
4393 return D_O_K;
4394 }
4395 int32_t onShowLayerO()
4396 {
4397 show_layer_over=!show_layer_over;
4398 return D_O_K;
4399 }
4400 int32_t onShowLayerP()
4401 {
4402 show_layer_push=!show_layer_push;
4403 return D_O_K;
4404 }
4405 int32_t onShowLayerS()
4406 {
4407 show_sprites=!show_sprites;
4408 return D_O_K;
4409 }
4410 int32_t onShowLayerF()
4411 {
4412 show_ffcs=!show_ffcs;
4413 return D_O_K;
4414 }
4415 int32_t onShowLayerW()
4416 {
4417 show_walkflags=!show_walkflags;
4418 return D_O_K;
4419 }
4420 int32_t onShowLayerE()
4421 {
4422 show_effectflags=!show_effectflags;
4423 return D_O_K;
4424 }
4425 int32_t onShowFFScripts()
4426 {
4427 show_ff_scripts=!show_ff_scripts;
4428 return D_O_K;
4429 }
4430 int32_t onShowHitboxes()
4431 {
4432 show_hitboxes=!show_hitboxes;
4433 return D_O_K;
4434 }
4435
4436 int32_t onLightSwitch()
4437 {
4438 cheats_enqueue(Cheat::Light);
4439 return D_O_K;
4440 }
4441
4442 int32_t onGoTo();
4443 int32_t onGoToComplete();
4444
4445 445220 void syskeys()
4446 {
4447 445220 update_system_keys();
4448
4449 int32_t oldtitle_version;
4450
4451
1/2
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
445220 if(close_button_quit)
4452 {
4453 close_button_quit=false;
4454 f_Quit(qEXIT);
4455 }
4456
4457 445220 poll_joystick();
4458
4459
2/10
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 445220 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
445220 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4460 {
4461 oldtitle_version=title_version;
4462 System();
4463 }
4464
4465 445220 mouse_down=gui_mouse_b();
4466
4467
1/2
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
445220 if(zc_read_system_key(KEY_F1))
4468 {
4469 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4470 {
4471 halt=!halt;
4472 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4473 }
4474 else
4475 {
4476 Throttlefps=!Throttlefps;
4477 logic_counter=0;
4478 }
4479 }
4480
4481 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4482 /*
4483 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4484 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4485 */
4486
4487
1/4
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
445220 if(zc_read_system_key(KEY_OPENBRACE)) if(frame_rest_suggest > 0) frame_rest_suggest--;
4488
4489
1/4
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
445220 if(zc_read_system_key(KEY_CLOSEBRACE)) if(frame_rest_suggest <= 2) frame_rest_suggest++;
4490
4491
1/2
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
445220 if(zc_read_system_key(KEY_F2)) ShowFPS=!ShowFPS;
4492
4493
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 445220 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
445220 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4494
4495
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 445220 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
445220 if(zc_read_system_key(KEY_F4) && Playing)
4496 {
4497 Paused=true;
4498 Advance=true;
4499 }
4500
4501
1/2
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
445220 if(zc_read_system_key(KEY_F6)) onTryQuit();
4502
4503 #ifndef ALLEGRO_MACOSX
4504 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4505
4506 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4507 #else
4508
1/2
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
445220 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4509
4510
1/2
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
445220 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4511 #endif
4512
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 445220 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
445220 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4513
4514
1/2
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
445220 if (zc_read_system_key(KEY_F12))
4515 {
4516 onSnapshot();
4517 }
4518
4519
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 445220 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
445220 if(debug_enabled && zc_read_system_key(KEY_TAB))
4520 set_debug(!get_debug());
4521
4522
3/4
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 431377 times.
445220 if(get_debug() || cheat>=1)
4523 {
4524
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4525 {
4526 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4527
4528 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4529
4530 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4531
4532 if(zc_readkey(KEY_B))
4533 {
4534 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4535 }
4536
4537 if(zc_readkey(KEY_A))
4538 {
4539 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4540 }
4541 }
4542 13843 }
4543
4544
3/4
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 431377 times.
445220 if(get_debug() || cheat>=2)
4545 {
4546
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4547 {
4548 if(rI())
4549 {
4550 cheats_enqueue(Cheat::Clock);
4551 }
4552 }
4553 13843 }
4554
4555
3/4
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13843 times.
✓ Branch 3 taken 431377 times.
445220 if(get_debug() || cheat>=4)
4556 {
4557
1/2
✓ Branch 0 taken 13843 times.
✗ Branch 1 not taken.
13843 if( CheatModifierKeys() )
4558 {
4559 if(rF11())
4560 {
4561 cheats_enqueue(Cheat::Walls);
4562 }
4563
4564 if(rQ())
4565 {
4566 cheats_enqueue(Cheat::Fast);
4567 }
4568
4569 if(zc_readkey(KEY_F))
4570 {
4571 cheats_enqueue(Cheat::Freeze);
4572 }
4573
4574 if(zc_readkey(KEY_G)) onGoToComplete();
4575
4576 if(zc_readkey(KEY_0)) onShowLayer0();
4577
4578 if(zc_readkey(KEY_1)) onShowLayer1();
4579
4580 if(zc_readkey(KEY_2)) onShowLayer2();
4581
4582 if(zc_readkey(KEY_3)) onShowLayer3();
4583
4584 if(zc_readkey(KEY_4)) onShowLayer4();
4585
4586 if(zc_readkey(KEY_5)) onShowLayer5();
4587
4588 if(zc_readkey(KEY_6)) onShowLayer6();
4589
4590 //if(zc_readkey(KEY_7)) onShowLayerO();
4591 if(zc_readkey(KEY_7)) onShowLayerF();
4592
4593 if(zc_readkey(KEY_8)) onShowLayerS();
4594
4595 if(zc_readkey(KEY_W)) onShowLayerW();
4596
4597 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4598
4599 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4600
4601 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4602 if(zc_readkey(KEY_O)) onShowLayerO();
4603 if(zc_readkey(KEY_P)) onShowLayerP();
4604 if(zc_readkey(KEY_C)) onShowHitboxes();
4605 if(zc_readkey(KEY_F)) onShowFFScripts();
4606 }
4607 13843 }
4608
4609
1/2
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
445220 if(volkeys)
4610 {
4611 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4612
4613 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4614
4615 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4616
4617 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4618 }
4619
4620
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 445220 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
445220 if(!get_debug() || !SystemKeys || replay_is_replaying())
4621 445220 goto bottom;
4622
4623 if(zc_readkey(KEY_D))
4624 {
4625 details = !details;
4626 rectfill(screen,0,0,319,7,BLACK);
4627 rectfill(screen,0,8,31,239,BLACK);
4628 rectfill(screen,288,8,319,239,BLACK);
4629 rectfill(screen,32,232,287,239,BLACK);
4630 }
4631
4632 if(zc_readkey(KEY_P)) Paused=!Paused;
4633
4634 //if(zc_readkey(KEY_P)) centerHero();
4635 if(zc_readkey(KEY_A))
4636 {
4637 Paused=true;
4638 Advance=true;
4639 }
4640
4641 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4642 #ifndef ALLEGRO_MACOSX
4643 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4644
4645 if(zc_readkey(KEY_F7))
4646 {
4647 Matrix(ss_speed, ss_density, 0);
4648 game_pal();
4649 }
4650 #else
4651 // The reason these are different on Mac in the first place is that
4652 // the OS doesn't let us use F9 and F10...
4653 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4654
4655 if(zc_readkey(KEY_F9))
4656 {
4657 Matrix(ss_speed, ss_density, 0);
4658 game_pal();
4659 }
4660 #endif
4661 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4662 {
4663 //change containers
4664 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4665 {
4666 //magic containers
4667 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4668 {
4669 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4670 }
4671 else
4672 {
4673 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4674 }
4675 }
4676 else
4677 {
4678 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4679 {
4680 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4681 }
4682 else
4683 {
4684 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4685 }
4686 }
4687 }
4688
4689 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4690 {
4691 //change containers
4692 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4693 {
4694 //magic containers
4695 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4696 {
4697 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4698 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4699 //heart containers
4700 }
4701 else
4702 {
4703 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4704 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4705 }
4706 }
4707 else
4708 {
4709 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4710 {
4711 game->set_magic(zc_max(game->get_magic()-1,0));
4712 }
4713 else
4714 {
4715 game->set_life(zc_max(game->get_life()-1,0));
4716 }
4717 }
4718 }
4719
4720 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4721
4722 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4723
4724 verifyBothWeapons();
4725
4726 bottom:
4727
4728
1/2
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
445220 if(input_idle(true) > after_time())
4729 {
4730 Matrix(ss_speed, ss_density, 0);
4731 game_pal();
4732 }
4733 //Saffith's method of separating system and game key bindings. Can't do this!!
4734 //restoreInput(); //This caused input to become randomly 'stuck'. -Z
4735
4736 //while(Playing && keypressed())
4737 //readkey();
4738 // What's the Playing check for?
4739 445220 clear_keybuf();
4740 445220 }
4741
4742 55900 void checkQuitKeys()
4743 {
4744 #ifndef ALLEGRO_MACOSX
4745 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4746
4747 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4748 #else
4749
1/2
✓ Branch 0 taken 55900 times.
✗ Branch 1 not taken.
55900 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4750
4751
1/2
✓ Branch 0 taken 55900 times.
✗ Branch 1 not taken.
55900 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4752 #endif
4753 55900 }
4754
4755 41529 bool CheatModifierKeys()
4756 {
4757 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4758 // to trigger cheats.
4759
1/2
✓ Branch 0 taken 41529 times.
✗ Branch 1 not taken.
41529 if (replay_is_replaying())
4760 41529 return false;
4761
4762 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4763 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4764 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4765 {
4766 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4767 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4768 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4769 {
4770 return true;
4771 }
4772 }
4773 return false;
4774 41529 }
4775
4776 //99:05:54, for some reason?
4777 #define OLDMAXTIME 21405240
4778 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4779 #define MAXTIME 1944000000
4780
4781 435426 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4782 {
4783
2/2
✓ Branch 0 taken 201528 times.
✓ Branch 1 taken 233898 times.
435426 if(zcmusic!=NULL)
4784 {
4785 233898 zcmusic_poll();
4786 233898 }
4787
4788
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 435426 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 435426 times.
435426 while(Paused && !Advance && !Quit)
4789 {
4790 // have to call this, otherwise we'll get an infinite loop
4791 syskeys();
4792 if(allowF6Script)
4793 {
4794 FFCore.runF6Engine();
4795 }
4796 if (replay_get_mode() != ReplayMode::Assert)
4797 updatescr(allowwavy);
4798 throttleFPS();
4799
4800 #ifdef _WIN32
4801
4802 if(use_dwm_flush)
4803 {
4804 do_DwmFlush();
4805 }
4806
4807 #endif
4808
4809 // to keep music playing
4810 if(zcmusic!=NULL)
4811 {
4812 zcmusic_poll();
4813 }
4814
4815 update_hw_screen();
4816 }
4817
4818
2/2
✓ Branch 0 taken 435420 times.
✓ Branch 1 taken 6 times.
435426 if(Quit)
4819 6 return;
4820
4821
3/4
✓ Branch 0 taken 431132 times.
✓ Branch 1 taken 4288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 431132 times.
435420 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4822 431132 game->change_time(1);
4823
4824 435420 Advance=false;
4825
4826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435420 times.
435420 if (replay_is_active())
4827 {
4828
2/2
✓ Branch 0 taken 390712 times.
✓ Branch 1 taken 44708 times.
435420 if (replay_get_version() >= 3)
4829 44708 replay_poll();
4830
2/2
✓ Branch 0 taken 424667 times.
✓ Branch 1 taken 10753 times.
435420 if (replay_get_version() >= 6)
4831 10753 replay_peek_input();
4832 435420 }
4833 435420 update_keys();
4834
4835 435420 ++frame;
4836
4837
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435420 times.
435420 if (replay_is_replaying())
4838 435420 replay_do_cheats();
4839 435420 syskeys();
4840
4841 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4842 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4843 // approach here means it doesn't matter which call adds the cheat.
4844 435420 cheats_execute_queued();
4845
4846
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435420 times.
435420 if (replay_is_replaying())
4847 435420 replay_peek_quit();
4848
2/2
✓ Branch 0 taken 435419 times.
✓ Branch 1 taken 1 times.
435420 if (GameFlags & GAMEFLAG_TRYQUIT)
4849 1 replay_step_quit(0);
4850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435420 times.
435420 if(allowF6Script)
4851 {
4852 435420 FFCore.runF6Engine();
4853 435420 }
4854
2/2
✓ Branch 0 taken 435399 times.
✓ Branch 1 taken 21 times.
435420 if (Quit)
4855 21 replay_step_quit(Quit);
4856 // Someday... maybe install a Turbo button here?
4857 435420 updatescr(allowwavy);
4858 435420 throttleFPS();
4859
4860 #ifdef _WIN32
4861
4862 if(use_dwm_flush)
4863 {
4864 do_DwmFlush();
4865 }
4866
4867 #endif
4868
4869 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 435420 times.
435420 if(sfxcleanup)
4871 435420 sfx_cleanup();
4872 435426 }
4873
4874 void zapout()
4875 {
4876 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4877 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4878
4879 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4880 script_drawing_commands.Clear();
4881
4882 // zap out
4883 for(int32_t i=1; i<=24; i++)
4884 {
4885 draw_fuzzy(i);
4886 syskeys();
4887 advanceframe(true);
4888
4889 if(Quit)
4890 {
4891 break;
4892 }
4893 }
4894 }
4895
4896 void zapin()
4897 {
4898 FFCore.warpScriptCheck();
4899 draw_screen(tmpscr);
4900 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4901 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4902 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4903
4904 // zap out
4905 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4906 for(int32_t i=24; i>=1; i--)
4907 {
4908 draw_fuzzy(i);
4909 syskeys();
4910 advanceframe(true);
4911
4912 if(Quit)
4913 {
4914 break;
4915 }
4916 }
4917 }
4918
4919
4920 void wavyout(bool showhero)
4921 {
4922 draw_screen(tmpscr, showhero);
4923 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4924
4925 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4926 clear_to_color(wavebuf,0);
4927 blit(framebuf,wavebuf,0,0,16,0,256,224);
4928
4929 static PALETTE wavepal;
4930
4931 int32_t ofs;
4932 int32_t amplitude=8;
4933
4934 int32_t wavelength=4;
4935 double palpos=0, palstep=4, palstop=126;
4936
4937 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4938 for(int32_t i=0; i<168; i+=wavelength)
4939 {
4940 for(int32_t l=0; l<256; l++)
4941 {
4942 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4943 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4944 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4945 }
4946
4947 palpos+=palstep;
4948
4949 if(palpos>=0)
4950 {
4951 hw_palette = &wavepal;
4952 update_hw_pal = true;
4953 }
4954 else
4955 {
4956 hw_palette = &RAMpal;
4957 update_hw_pal = true;
4958 }
4959
4960 for(int32_t j=0; j+playing_field_offset<224; j++)
4961 {
4962 for(int32_t k=0; k<256; k++)
4963 {
4964 ofs=0;
4965
4966 if((j<i)&&(j&1))
4967 {
4968 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4969 }
4970
4971 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4972 }
4973 }
4974
4975 syskeys();
4976 advanceframe(true);
4977
4978 // animate_combos();
4979 if(Quit)
4980 break;
4981 }
4982
4983 destroy_bitmap(wavebuf);
4984 }
4985
4986 void wavyin()
4987 {
4988 draw_screen(tmpscr);
4989 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4990
4991 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4992 clear_to_color(wavebuf,0);
4993 blit(framebuf,wavebuf,0,0,16,0,256,224);
4994
4995 static PALETTE wavepal;
4996
4997 //Breaks dark rooms.
4998 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4999 /*
5000 loadfullpal();
5001 loadlvlpal(DMaps[currdmap].color);
5002 ringcolor(false);
5003 */
5004 refreshpal=false;
5005 int32_t ofs;
5006 int32_t amplitude=8;
5007 int32_t wavelength=4;
5008 double palpos=168, palstep=4, palstop=126;
5009
5010 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
5011 for(int32_t i=0; i<168; i+=wavelength)
5012 {
5013 for(int32_t l=0; l<256; l++)
5014 {
5015 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
5016 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
5017 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
5018 }
5019
5020 palpos-=palstep;
5021
5022 if(palpos>=0)
5023 {
5024 hw_palette = &wavepal;
5025 update_hw_pal = true;
5026 }
5027 else
5028 {
5029 hw_palette = &RAMpal;
5030 update_hw_pal = true;
5031 }
5032
5033 for(int32_t j=0; j+playing_field_offset<224; j++)
5034 {
5035 for(int32_t k=0; k<256; k++)
5036 {
5037 ofs=0;
5038
5039 if((j<(167-i))&&(j&1))
5040 {
5041 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
5042 }
5043
5044 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
5045 }
5046 }
5047
5048 syskeys();
5049 advanceframe(true);
5050 // animate_combos();
5051
5052 if(Quit)
5053 break;
5054 }
5055
5056 destroy_bitmap(wavebuf);
5057 }
5058
5059 181 void blackscr(int32_t fcnt,bool showsubscr)
5060 {
5061 181 reset_pal_cycling();
5062 181 script_drawing_commands.Clear();
5063
5064 181 FFCore.warpScriptCheck();
5065 181 bool showtime = game->should_show_time();
5066
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 5430 times.
5611 while(fcnt>0)
5067 {
5068 5430 clear_bitmap(framebuf);
5069
5070
2/2
✓ Branch 0 taken 1170 times.
✓ Branch 1 taken 4260 times.
5430 if(showsubscr)
5071 {
5072 4260 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5073
3/4
✓ Branch 0 taken 4260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 4230 times.
4260 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5074 {
5075 30 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5076 30 }
5077 4260 }
5078
5079 5430 syskeys();
5080 5430 advanceframe(true);
5081
5082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5430 times.
5430 if(Quit)
5083 break;
5084
5085 5430 --fcnt;
5086 }
5087 181 }
5088
5089 59 void openscreen(int32_t shape)
5090 {
5091 59 reset_pal_cycling();
5092 59 black_opening_count=0;
5093
5094
3/4
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
59 if(COOLSCROLL || shape>-1)
5095 {
5096 25 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5097 25 return;
5098 }
5099 else
5100 {
5101 34 Hero.setDontDraw(true);
5102 34 show_subscreen_dmap_dots=false;
5103 34 show_subscreen_numbers=false;
5104 // show_subscreen_items=false;
5105 34 show_subscreen_life=false;
5106 }
5107
5108 34 int32_t x=128;
5109
5110 34 FFCore.warpScriptCheck();
5111
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 2720 times.
2754 for(int32_t i=0; i<80; i++)
5112 {
5113 2720 draw_screen(tmpscr);
5114 //? draw_screen already draws the subscreen -DD
5115 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5116 2720 x=128-(((i*128/80)/8)*8);
5117
5118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2720 times.
2720 if(x>0)
5119 {
5120 2720 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5121 2720 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5122 2720 }
5123
5124 // x=((80-i)/2)*4;
5125 /*
5126 --x;
5127 switch(++c)
5128 {
5129 case 5: c=0;
5130 case 0:
5131 case 2:
5132 case 3: --x; break;
5133 }
5134 */
5135 2720 syskeys();
5136 2720 advanceframe(true);
5137
5138
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2720 times.
2720 if(Quit)
5139 {
5140 break;
5141 }
5142 2720 }
5143
5144 34 Hero.setDontDraw(false);
5145 34 show_subscreen_items=true;
5146 34 show_subscreen_dmap_dots=true;
5147 59 }
5148
5149 void closescreen(int32_t shape)
5150 {
5151 reset_pal_cycling();
5152 black_opening_count=0;
5153
5154 if(COOLSCROLL || shape>-1)
5155 {
5156 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5157 return;
5158 }
5159 else
5160 {
5161 Hero.setDontDraw(true);
5162 show_subscreen_dmap_dots=false;
5163 show_subscreen_numbers=false;
5164 // show_subscreen_items=false;
5165 show_subscreen_life=false;
5166 }
5167
5168 int32_t x=128;
5169
5170 FFCore.warpScriptCheck();
5171 for(int32_t i=79; i>=0; --i)
5172 {
5173 draw_screen(tmpscr);
5174 //? draw_screen already draws the subscreen -DD
5175 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5176 x=128-(((i*128/80)/8)*8);
5177
5178 if(x>0)
5179 {
5180 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5181 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5182 }
5183
5184 // x=((80-i)/2)*4;
5185 /*
5186 --x;
5187 switch(++c)
5188 {
5189 case 5: c=0;
5190 case 0:
5191 case 2:
5192 case 3: --x; break;
5193 }
5194 */
5195 syskeys();
5196 advanceframe(true);
5197
5198 if(Quit)
5199 {
5200 break;
5201 }
5202 }
5203
5204 Hero.setDontDraw(false);
5205 show_subscreen_items=true;
5206 show_subscreen_dmap_dots=true;
5207 }
5208
5209 4 int32_t TriforceCount()
5210 {
5211 4 int32_t c=0;
5212
5213
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4 times.
36 for(int32_t i=1; i<=8; i++)
5214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
64 if(game->lvlitems[i]&liTRIFORCE)
5215 32 ++c;
5216
5217 4 return c;
5218 }
5219
5220 int32_t onCustomGame()
5221 {
5222 int32_t file = getsaveslot();
5223
5224 if(file < 0)
5225 return D_O_K;
5226
5227 bool ret = (custom_game(file)!=0);
5228 return ret ? D_CLOSE : D_O_K;
5229 }
5230
5231 int32_t onContinue()
5232 {
5233 return D_CLOSE;
5234 }
5235
5236 int32_t onEsc() // Unused?? -L
5237 {
5238 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5239 }
5240
5241 int32_t onVsync()
5242 {
5243 Throttlefps = !Throttlefps;
5244 save_game_configs();
5245 return D_O_K;
5246 }
5247
5248 int32_t onWinPosSave()
5249 {
5250 SaveWinPos = !SaveWinPos;
5251 return D_O_K;
5252 }
5253
5254 int32_t onClickToFreeze()
5255 {
5256 ClickToFreeze = !ClickToFreeze;
5257 save_game_configs();
5258 return D_O_K;
5259 }
5260
5261 int32_t OnSaveZCConfig()
5262 {
5263 if(jwin_alert3(
5264 "Save Configuration",
5265 "Are you sure that you wish to save your present configuration settings?",
5266 "This will overwrite your prior settings!",
5267 NULL,
5268 "&Yes",
5269 "&No",
5270 NULL,
5271 'y',
5272 'n',
5273 0,
5274 lfont) == 1)
5275 {
5276 save_game_configs();
5277 return D_O_K;
5278 }
5279 else return D_O_K;
5280 }
5281
5282 int32_t OnnClearQuestDir()
5283 {
5284 if(jwin_alert3(
5285 "Clear Current Directory Cache",
5286 "Are you sure that you wish to clear the current cached directory?",
5287 "This will default the current directory to the ROOT for this instance of ZC Player!",
5288 NULL,
5289 "&Yes",
5290 "&No",
5291 NULL,
5292 'y',
5293 'n',
5294 0,
5295 lfont) == 1)
5296 {
5297 set_config_string("zeldadx","win_qst_dir","");
5298 flush_config_file();
5299 strcpy(qstdir,get_config_string("zeldadx","win_qst_dir",""));
5300 //strcpy(filepath,get_config_string("zeldadx","win_qst_dir",""));
5301 save_game_configs();
5302 #ifdef __EMSCRIPTEN__
5303 em_sync_fs();
5304 #endif
5305 return D_O_K;
5306 }
5307 else return D_O_K;
5308 }
5309
5310
5311 int32_t onConsoleZASM()
5312 {
5313 if ( !zasm_debugger )
5314 {
5315 AlertDialog("WARNING: ZASM Debugger",
5316 "Enabling this will open the ZASM Debugger Console"
5317 "\nThis will likely grind ZC to a halt with lag."
5318 "\nTo make any use of this, it is suggested that you read"
5319 "\nthe documentation for 'void Breakpoint(char[] string);'"
5320 " in 'ZScript_Additions.txt'"
5321 "\nThis is not recommended for normal users,"
5322 " and is only intended for ZC developers,"
5323 "\nor quest developers coding directly in ZASM"
5324 "\nAre you sure that you wish to open the ZASM Debugger?",
5325 [&](bool ret,bool)
5326 {
5327 if(ret)
5328 {
5329 FFCore.ZASMPrint(true);
5330 zasm_debugger = 1;
5331 save_game_configs();
5332 }
5333 }).show();
5334 return D_O_K;
5335 }
5336 else
5337 {
5338 zasm_debugger = 0;
5339 save_game_configs();
5340 FFCore.ZASMPrint(false);
5341 return D_O_K;
5342 }
5343 }
5344
5345
5346 int32_t onConsoleZScript()
5347 {
5348 if ( !zscript_debugger )
5349 {
5350 AlertDialog("ZScript Debugger",
5351 "Enabling this will open the ZScript Debugger Console"
5352 "\nThis will display any messages logged by scripts,"
5353 " including script errors."
5354 "\nAre you sure that you wish to open the ZScript Debugger?",
5355 [&](bool ret,bool)
5356 {
5357 if(ret)
5358 {
5359 FFCore.ZScriptConsole(true);
5360 zscript_debugger = 1;
5361 save_game_configs();
5362 }
5363 }).show();
5364 return D_O_K;
5365 }
5366 else
5367 {
5368 zscript_debugger = 0;
5369 save_game_configs();
5370 FFCore.ZScriptConsole(false);
5371 return D_O_K;
5372 }
5373 }
5374
5375
5376 int32_t onFrameSkip()
5377 {
5378 FrameSkip = !FrameSkip;
5379 return D_O_K;
5380 }
5381
5382 int32_t onSaveDragResize()
5383 {
5384 SaveDragResize = !SaveDragResize;
5385 return D_O_K;
5386 }
5387
5388 int32_t onDragAspect()
5389 {
5390 DragAspect = !DragAspect;
5391 return D_O_K;
5392 }
5393
5394 int32_t onTransLayers()
5395 {
5396 TransLayers = !TransLayers;
5397 save_game_configs();
5398 return D_O_K;
5399 }
5400
5401 int32_t onNESquit()
5402 {
5403 NESquit = !NESquit;
5404 save_game_configs();
5405 return D_O_K;
5406 }
5407
5408 int32_t onVolKeys()
5409 {
5410 volkeys = !volkeys;
5411 save_game_configs();
5412 return D_O_K;
5413 }
5414
5415 int32_t onShowFPS()
5416 {
5417 ShowFPS = !ShowFPS;
5418 save_game_configs();
5419 return D_O_K;
5420 }
5421
5422 52535960 bool is_Fkey(int32_t k)
5423 {
5424
2/2
✓ Branch 0 taken 5342640 times.
✓ Branch 1 taken 47193320 times.
52535960 switch(k)
5425 {
5426 case KEY_F1:
5427 case KEY_F2:
5428 case KEY_F3:
5429 case KEY_F4:
5430 case KEY_F5:
5431 case KEY_F6:
5432 case KEY_F7:
5433 case KEY_F8:
5434 case KEY_F9:
5435 case KEY_F10:
5436 case KEY_F11:
5437 case KEY_F12:
5438 5342640 return true;
5439 }
5440
5441 47193320 return false;
5442 52535960 }
5443
5444 void kb_getkey(DIALOG *d)
5445 {
5446 d->flags|=D_SELECTED;
5447
5448 scare_mouse();
5449 jwin_button_proc(MSG_DRAW,d,0);
5450 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5451 // text_mode(vc(11));
5452 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5453 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5454 unscare_mouse();
5455
5456 update_hw_screen(true);
5457
5458 clear_keybuf();
5459 int32_t k = next_press_key();
5460 clear_keybuf();
5461
5462 //shnarf
5463 //47=f1
5464 //59=esc
5465 if(k>0 && k<123 && !((k>46)&&(k<60)))
5466 *((int32_t*)d->dp3) = k;
5467
5468
5469 d->flags&=~D_SELECTED;
5470 }
5471
5472
5473 //Used by all keyboard key settings dialogues.
5474 void kb_clearjoystick(DIALOG *d)
5475 {
5476 d->flags|=D_SELECTED;
5477
5478 scare_mouse();
5479 jwin_button_proc(MSG_DRAW,d,0);
5480 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5481 // text_mode(vc(11));
5482 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5483 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5484 unscare_mouse();
5485
5486 update_hw_screen(true);
5487
5488 clear_keybuf();
5489 int32_t k = next_press_key();
5490 clear_keybuf();
5491
5492 //shnarf
5493 //47=f1
5494 //59=esc
5495 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5496 // *((int32_t*)d->dp3) = k;
5497 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5498
5499
5500 d->flags&=~D_SELECTED;
5501 }
5502
5503 //Clears key to 0.
5504 //Used by all keyboard key settings dialogues.
5505 void kb_clearkey(DIALOG *d)
5506 {
5507 d->flags|=D_SELECTED;
5508
5509 scare_mouse();
5510 jwin_button_proc(MSG_DRAW,d,0);
5511 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5512 // text_mode(vc(11));
5513 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5514 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5515 unscare_mouse();
5516
5517 update_hw_screen(true);
5518
5519 clear_keybuf();
5520 int32_t k = next_press_key();
5521 clear_keybuf();
5522
5523 //shnarf
5524 //47=f1
5525 //59=esc
5526 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5527 // *((int32_t*)d->dp3) = k;
5528 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5529
5530
5531 d->flags&=~D_SELECTED;
5532 }
5533
5534
5535 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5536 {
5537 switch(msg)
5538 {
5539 case MSG_KEY:
5540 case MSG_CLICK:
5541
5542 kb_clearjoystick(d);
5543
5544 while(gui_mouse_b())
5545 {
5546 clear_keybuf();
5547 rest(1);
5548 }
5549
5550 return D_REDRAW;
5551 }
5552
5553 return jwin_button_proc(msg,d,c);
5554 }
5555
5556 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5557 {
5558 switch(msg)
5559 {
5560 case MSG_KEY:
5561 case MSG_CLICK:
5562
5563 kb_getkey(d);
5564
5565 while(gui_mouse_b()) {
5566 clear_keybuf();
5567 rest(1);
5568 }
5569
5570 return D_REDRAW;
5571 }
5572
5573 return jwin_button_proc(msg,d,c);
5574 }
5575
5576 //Only used in keyboard settings dialogues to clear keys.
5577 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5578 {
5579 switch(msg)
5580 {
5581 case MSG_KEY:
5582 case MSG_CLICK:
5583
5584 kb_clearkey(d);
5585
5586 while(gui_mouse_b()) {
5587 clear_keybuf();
5588 rest(1);
5589 }
5590
5591 return D_REDRAW;
5592 }
5593
5594 return jwin_button_proc(msg,d,c);
5595 }
5596
5597 void j_getbtn(DIALOG *d)
5598 {
5599 d->flags|=D_SELECTED;
5600 scare_mouse();
5601 jwin_button_proc(MSG_DRAW,d,0);
5602 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5603 // text_mode(vc(11));
5604 int32_t y = gui_bmp->h/2 - 12;
5605 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5606 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5607 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5608 unscare_mouse();
5609
5610 update_hw_screen(true);
5611
5612 int32_t b = next_press_btn();
5613
5614 if(b>=0)
5615 *((int32_t*)d->dp3) = b;
5616
5617 d->flags&=~D_SELECTED;
5618
5619 if (player)
5620 player->joy_on = TRUE;
5621 }
5622
5623 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5624 {
5625 switch(msg)
5626 {
5627 case MSG_KEY:
5628 case MSG_CLICK:
5629
5630 j_getbtn(d);
5631
5632 while(gui_mouse_b()) {
5633 rest(1);
5634 clear_keybuf();
5635 }
5636
5637 return D_REDRAW;
5638 }
5639
5640 return jwin_button_proc(msg,d,c);
5641 }
5642
5643 //shnarf
5644 const char *key_str[] =
5645 {
5646 "(none) ", "a ", "b ", "c ",
5647 "d ", "e ", "f ", "g ",
5648 "h ", "i ", "j ", "k ",
5649 "l ", "m ", "n ", "o ",
5650 "p ", "q ", "r ", "s ",
5651 "t ", "u ", "v ", "w ",
5652 "x ", "y ", "z ", "0 ",
5653 "1 ", "2 ", "3 ", "4 ",
5654 "5 ", "6 ", "7 ", "8 ",
5655 "9 ", "num 0 ", "num 1 ", "num 2 ",
5656 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5657 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5658 "f2 ", "f3 ", "f4 ", "f5 ",
5659 "f6 ", "f7 ", "f8 ", "f9 ",
5660 "f10 ", "f11 ", "f12 ", "esc ",
5661 "~ ", "- ", "= ", "backspace ",
5662 "tab ", "{ ", "} ", "enter ",
5663 ": ", "quote ", "\\ ", "\\ (2) ",
5664 ", ", ". ", "/ ", "space ",
5665 "insert ", "delete ", "home ", "end ",
5666 "page up ", "page down ", "left ", "right ",
5667 "up ", "down ", "num / ", "num * ",
5668 "num - ", "num + ", "num delete ", "num enter ",
5669 "print screen ", "pause ", "abnt c1 ", "yen ",
5670 "kana ", "convert ", "no convert ", "at ",
5671 "circumflex ", ": (2) ", "kanji ", "num = ",
5672 "back quote ", "; ", "command ", "unknown (0) ",
5673 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5674 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5675 "right shift ", "left control ", "right control", "alt ",
5676 "alt gr ", "left win ", "right win ", "menu ",
5677 "scroll lock ", "number lock ", "caps lock ", "MAX"
5678 };
5679
5680
5681 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5682 //extern int32_t zcmusic_bufsz;
5683
5684 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5685 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5686
5687 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5688 {
5689 //these are here to bypass compiler warnings about unused arguments
5690 c=c;
5691
5692 if(msg==MSG_DRAW)
5693 {
5694 switch(d->w)
5695 {
5696 case 0:
5697 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5698 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5699 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5700 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5701 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5702 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5703 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5704 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5705 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5706 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5707 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5708 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5709 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5710 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5711 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5712 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5713 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5714 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5715 break;
5716
5717 case 1:
5718 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5719 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5720 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5721 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5722 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5723 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5724 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5725 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5726 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5727 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5728 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5729 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5730 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5731 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5732 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5733 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5734 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5735 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5736 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5737 break;
5738
5739 case 2:
5740 sprintf(str_a,"%3d",midi_volume);
5741 sprintf(str_b,"%3d",digi_volume);
5742 sprintf(str_l,"%3d",emusic_volume);
5743 sprintf(str_m,"%3dKB",zcmusic_bufsz);
5744 sprintf(str_r,"%3d",sfx_volume);
5745 strcpy(str_s,pan_str[pan_style]);
5746 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5747 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5748 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5749 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5750 break;
5751 }
5752 }
5753
5754 return D_O_K;
5755 }
5756
5757 int32_t set_vol(void *dp3, int32_t d2)
5758 {
5759 switch(((int32_t*)dp3)[0])
5760 {
5761 case 0:
5762 midi_volume = zc_min(d2<<3,255);
5763 break;
5764
5765 case 1:
5766 digi_volume = zc_min(d2<<3,255);
5767 break;
5768
5769 case 2:
5770 emusic_volume = zc_min(d2<<3,255);
5771 break;
5772
5773 case 3:
5774 sfx_volume = zc_min(d2<<3,255);
5775 break;
5776 }
5777
5778 scare_mouse();
5779 // text_mode(vc(11));
5780 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5781 unscare_mouse();
5782 return D_O_K;
5783 }
5784
5785 int32_t set_pan(void *dp3, int32_t d2)
5786 {
5787 pan_style = vbound(d2,0,3);
5788 scare_mouse();
5789 // text_mode(vc(11));
5790 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5791 unscare_mouse();
5792 return D_O_K;
5793 }
5794
5795 int32_t set_buf(void *dp3, int32_t d2)
5796 {
5797 scare_mouse();
5798 // text_mode(vc(11));
5799 zcmusic_bufsz = d2 + 1;
5800 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5801 unscare_mouse();
5802 return D_O_K;
5803 }
5804
5805 static int32_t gamepad_btn_list[] =
5806 {
5807 6,
5808 7,8,9,10,11,12,13,14,15,16,17,
5809 18,19,20,21,22,23,24,25,26,27,28,
5810 29,30,31,32,33,34,35,36,37,38,39,
5811 -1
5812 };
5813
5814 static int32_t gamepad_dirs_list[] =
5815 {
5816 40,41,42,43,
5817 44,45,46,47,
5818 48,49,50,51,
5819 52,53,54,55,
5820 56,
5821 -1
5822 };
5823
5824 static TABPANEL gamepad_tabs[] =
5825 {
5826 // (text)
5827 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5828 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5829 { NULL, 0, NULL, 0, NULL }
5830 };
5831
5832 static DIALOG gamepad_dlg[] =
5833 {
5834 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5835 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5836 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5837 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5838 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5839 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5840 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5841 // 6
5842 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5843 // 7
5844 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5845 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5846 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5847 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5848 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5849 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5850 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5851 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5852 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5853 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5854 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5855 // 18
5856 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5857 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5858 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5859 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5860 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5861 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5862 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5863 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5864 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5865 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5866 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5867 // 29
5868 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5869 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5870 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5871 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5872 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5873 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5874 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5875 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5876 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5877 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5878 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5879 // 40
5880 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5881 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5882 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5883 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5884 // 44
5885 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5886 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5887 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5888 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5889 // 48
5890 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5891 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5892 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5893 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5894 // 52
5895 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5896 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5897 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5898 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5899 // 56
5900 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5901 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5902 };
5903
5904 static int32_t keyboard_keys_list[] =
5905 {
5906 6,7,8,9,10,
5907 11,12,13,14,15,16,17,18,19,20,
5908 21,22,23,24,25,26,27,28,29,30,
5909 31,32,33,34,35,36,37,38,39,40,
5910 -1
5911 };
5912
5913 static int32_t keyboard_dirs_list[] =
5914 {
5915 41,42,43,44,
5916 45,46,47,48,
5917 49,50,51,52,
5918 53,54,55,56,
5919 -1
5920 };
5921
5922 static int32_t keyboard_mods_list[] =
5923 {
5924 57,58,59,60,
5925 61,62,63,64,
5926 65,66,67,68,
5927 69,70,71,72,
5928 -1
5929 };
5930
5931 static TABPANEL keyboard_control_tabs[] =
5932 {
5933 // (text)
5934 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5935 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5936 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5937 { NULL, 0, NULL, 0, NULL }
5938 };
5939
5940 static DIALOG keyboard_control_dlg[] =
5941 {
5942 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5943 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5944 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5945 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5946 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5947 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5948 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5949 // Keys
5950 // 6
5951 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5952 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5953 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5954 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5955 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5956 // 11
5957 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5958 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5959 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5960 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5961 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5962 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5963 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5964 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5965 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5966 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5967 // 21
5968 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5969 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5970 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5971 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5972 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5973 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5974 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5975 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5976 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5977 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5978 // 31
5979 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5980 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5981 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5982 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5983 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5984 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5985 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5986 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5987 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5988 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5989 // Dirs
5990 // 41
5991 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5992 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5993 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5994 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5995 // 45
5996 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5997 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5998 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5999 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
6000 // 49
6001 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
6002 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
6003 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
6004 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
6005 // 53
6006 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
6007 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
6008 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
6009 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
6010 // Mods
6011 // 57
6012 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6013 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6014 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
6015 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
6016 // 61
6017 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
6018 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
6019 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
6020 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
6021 // 65
6022 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
6023 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
6024 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
6025 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
6026 // 69
6027 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
6028 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
6029 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
6030 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
6031 // 73
6032 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6033 };
6034
6035 /*
6036 int32_t midi_dp[3] = {0,147,104};
6037 int32_t digi_dp[3] = {1,147,120};
6038 int32_t pan_dp[3] = {0,147,136};
6039 int32_t buf_dp[3] = {0,147,152};
6040 */
6041 int32_t midi_dp[3] = {0,0,0};
6042 int32_t digi_dp[3] = {1,0,0};
6043 int32_t emus_dp[3] = {2,0,0};
6044 int32_t buf_dp[3] = {0,0,0};
6045 int32_t sfx_dp[3] = {3,0,0};
6046 int32_t pan_dp[3] = {0,0,0};
6047
6048 static DIALOG sound_dlg[] =
6049 {
6050 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
6051 9 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
6052 9 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6053 9 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6054 9 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6055 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6056 9 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6057 9 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
6058 9 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
6059 9 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
6060 9 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
6061 // 10
6062 9 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
6063 9 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
6064 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6065 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6066 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6067 9 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
6068 9 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
6069 9 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
6070 9 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
6071 9 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
6072 //20
6073 9 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
6074 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6075 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6076 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6077 9 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
6078 9 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
6079 9 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
6080 9 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
6081 9 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
6082 9 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
6083 //30
6084 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6085 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6086 9 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6087 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6088 };
6089
6090 char zc_builddate[80];
6091 char zc_aboutstr[80];
6092
6093 static DIALOG about_dlg[] =
6094 {
6095 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6096 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
6097 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6098 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
6099 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6100 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
6101 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
6102 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
6103 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
6104 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
6105 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6106 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6107 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6108 };
6109
6110
6111 static DIALOG quest_dlg[] =
6112 {
6113 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6114 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6115 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6116 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6117 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6118 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6119 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, QHeader.version, NULL, NULL },
6120 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6121 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6122 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6123 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6124 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6125 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6126 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6127 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6128 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6129 };
6130
6131 static DIALOG triforce_dlg[] =
6132 {
6133 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6134 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6135 // 1
6136 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6137 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6138 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6139 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6140 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6141 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6142 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6143 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6144 // 9
6145 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6146 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6147 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6148 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6149 };
6150
6151 /*static DIALOG equip_dlg[] =
6152 {
6153 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6154 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6155 // 1
6156 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6157 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6158 // 3
6159 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6160 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6161 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6162 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6163 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6164 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6165 // 9
6166 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6167 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6168 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6169 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6170 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6171 // 14
6172 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6173 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6174 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6175 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6176 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6177 // 19
6178 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6179 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6180 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6181 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6182 // 23
6183 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6184 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6185 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6186 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6187 // 27
6188 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6189 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6190 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6191 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6192 // 31
6193 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6194 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6195 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6196 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6197 // 35
6198 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6199 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6200 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6201 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6202 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6203 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6204 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6205 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6206 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6207 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6208 };
6209
6210 static DIALOG items_dlg[] =
6211 {
6212 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6213 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6214 //1
6215 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6216 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6217 // 3
6218 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6219 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6220 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6221 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6222 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6223 // 8
6224 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6225 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6226 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6227 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6228 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6229 // 13
6230 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6231 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6232 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6233 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6234 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6235 // 18
6236 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6237 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6238 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6239 // 21
6240 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6241 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6242 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6243 // 24
6244 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6245 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6246 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6247 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6248 // 28
6249 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6250 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6251 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6252 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6253 // 32
6254 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6255 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6256 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6257 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6258 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6259 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6260 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6261 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6262 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6263 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6264 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6265 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6266 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6267 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6268 //45
6269 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6270 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6271 };*/
6272
6273
6274
6275 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6276 {
6277 go();
6278 int32_t ret=0;
6279 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6280 comeback();
6281 return ret != 0;
6282 }
6283
6284
6285 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6286 {
6287 if(def!=modulepath)
6288 strcpy(modulepath,def);
6289
6290 if(!usefilename)
6291 {
6292 int32_t i=(int32_t)strlen(modulepath);
6293
6294 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6295 modulepath[i--]=0;
6296 }
6297
6298 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6299 int32_t ret=0;
6300 int32_t sel=0;
6301
6302 if(list==NULL)
6303 {
6304 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6305 }
6306 else
6307 {
6308 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6309 }
6310
6311 return ret!=0;
6312 }
6313
6314 //The Dialogue that loads a ZMOD Module File
6315 int32_t zc_load_zmod_module_file()
6316 {
6317 if ( Playing )
6318 {
6319 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6320 return -1;
6321 }
6322 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6323 return D_CLOSE;
6324
6325 FILE *tempmodule = fopen(modulepath,"r");
6326
6327 if(tempmodule == NULL)
6328 {
6329 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6330 return -1;
6331 }
6332
6333
6334 //Set the module path:
6335 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6336 strcpy(moduledata.module_name, modulepath);
6337 al_trace("New Module Path is: %s \n", moduledata.module_name);
6338 set_config_string("ZCMODULE","current_module",moduledata.module_name);
6339 //save_game_configs();
6340 zcm.init(true); //Load the module values.
6341 moduledata.refresh_title_screen = 1;
6342 // refresh_select_screen = 1;
6343 build_biic_list();
6344 return D_O_K;
6345 }
6346
6347 static DIALOG module_info_dlg[] =
6348 {
6349 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6350
6351
6352 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6353 //1
6354 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6355 //2
6356 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6357 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6358 //4
6359 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6360 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6361 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6362 //7
6363
6364 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6365 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6366 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6367 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6368 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6369 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6370 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6371 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6372 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6373
6374 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6375 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6376 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6377 };
6378
6379 void about_zcplayer_module(const char *prompt,int32_t initialval)
6380 {
6381
6382 module_info_dlg[0].dp2 = lfont;
6383 if ( moduledata.moduletitle[0] != 0 )
6384 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6385
6386 if ( moduledata.moduleauthor[0] != 0 )
6387 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6388
6389 if ( moduledata.moduleinfo0[0] != 0 )
6390 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6391 if ( moduledata.moduleinfo1[0] != 0 )
6392 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6393 if ( moduledata.moduleinfo2[0] != 0 )
6394 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6395 if ( moduledata.moduleinfo3[0] != 0 )
6396 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6397 if ( moduledata.moduleinfo4[0] != 0 )
6398 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6399
6400 char module_date[255];
6401 memset(module_date, 0, sizeof(module_date));
6402 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6403 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6404
6405
6406
6407 char module_vers[255];
6408 memset(module_vers, 0, sizeof(module_vers));
6409 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6410
6411
6412 //sprintf(tilecount,"%d",1);
6413
6414 char module_build[255];
6415 memset(module_build, 0, sizeof(module_build));
6416 if ( moduledata.modbeta )
6417 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6418 else
6419 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6420
6421 module_info_dlg[12].dp = (char*)module_date;
6422 module_info_dlg[13].dp = (char*)module_vers;
6423 module_info_dlg[14].dp = (char*)module_build;
6424
6425 if(is_large)
6426 large_dialog(module_info_dlg);
6427
6428 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6429 jwin_center_dialog(module_info_dlg);
6430
6431
6432 }
6433
6434 int32_t onAbout_ZCP_Module()
6435 {
6436 about_zcplayer_module("About Module (.zmod)", 0);
6437 return D_O_K;
6438 }
6439
6440 //New Modules Menu for 2.55+
6441 static MENU zcmodule_menu[] =
6442 {
6443 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6444 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6445
6446 { NULL, NULL, NULL, 0, NULL }
6447 };
6448
6449 int32_t onToggleRecordingNewSaves()
6450 {
6451 if (zc_get_config("zeldadx", "replay_new_saves", false))
6452 {
6453 zc_set_config("zeldadx", "replay_new_saves", false);
6454 }
6455 else
6456 {
6457 zc_set_config("zeldadx", "replay_new_saves", true);
6458 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6459 NULL,NULL,"OK",NULL,13,27,lfont);
6460 }
6461 return D_O_K;
6462 }
6463
6464 int32_t onStopReplayOrRecord()
6465 {
6466 if (replay_is_replaying())
6467 {
6468 replay_quit();
6469 }
6470 else if (replay_get_mode() == ReplayMode::Record)
6471 {
6472 if (!replay_get_meta_bool("test_mode"))
6473 {
6474 jwin_alert("Recording", "You cannot stop recording a save file.",
6475 NULL,NULL,"OK",NULL,13,27,lfont);
6476 return D_CLOSE;
6477 }
6478
6479 if (jwin_alert("Stop Recording",
6480 "Save replay to disk and stop recording?",
6481 "This will stop the recording.",
6482 NULL,
6483 "Yes","No",13,27,lfont) != 1)
6484 return D_CLOSE;
6485
6486 replay_save();
6487 replay_stop();
6488 }
6489 return D_O_K;
6490 }
6491
6492 static int32_t handle_on_load_replay(ReplayMode mode)
6493 {
6494 if (Playing)
6495 {
6496 if (jwin_alert("Replay - Warning!",
6497 "Loading a replay will exit the current game.",
6498 "All unsaved progress will be lost.",
6499 "Do you wish to continue?",
6500 "Yes","No",13,27,lfont) != 1)
6501 return D_CLOSE;
6502 }
6503
6504 std::string mode_string = replay_mode_to_string(mode);
6505 mode_string[0] = std::toupper(mode_string[0]);
6506
6507 std::string line_1 = "Select a replay file to play back.";
6508 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6509 std::string line_3 = "You can stop the replay and take over manually any time.";
6510 if (mode == ReplayMode::Update)
6511 {
6512 line_1 = "Select a replay file to update.";
6513 line_2 = "WARNING: be sure to back up the zplay file";
6514 line_3 = "and verify that the updated replay works as expected!";
6515 }
6516
6517 if (jwin_alert(mode_string.c_str(),
6518 line_1.c_str(),
6519 line_2.c_str(),
6520 line_3.c_str(),
6521 "OK","Nevermind",13,27,lfont) == 1)
6522 {
6523 char replay_path[2048];
6524 strcpy(replay_path, "replays/");
6525 if (jwin_file_select_ex(
6526 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6527 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6528 return D_CLOSE;
6529
6530 replay_quit();
6531 load_replay_file_deferred(mode, replay_path);
6532 Quit = qRESET;
6533 return D_CLOSE;
6534 }
6535 return D_O_K;
6536 }
6537
6538 int32_t onLoadReplay()
6539 {
6540 return handle_on_load_replay(ReplayMode::Replay);
6541 }
6542
6543 int32_t onLoadReplayAssert()
6544 {
6545 return handle_on_load_replay(ReplayMode::Assert);
6546 }
6547
6548 int32_t onLoadReplayUpdate()
6549 {
6550 return handle_on_load_replay(ReplayMode::Update);
6551 }
6552
6553 int32_t onSaveReplay()
6554 {
6555 if (replay_get_mode() == ReplayMode::Record)
6556 {
6557 if (!replay_get_meta_bool("test_mode"))
6558 {
6559 if (jwin_alert("Save Replay",
6560 "This will save a copy of the replay up to this point.",
6561 "The official replay file will be untouched.",
6562 "Do you wish to continue?",
6563 "Yes","No",13,27,lfont) != 1)
6564 return D_CLOSE;
6565
6566 char replay_path[2048];
6567 strcpy(replay_path, replay_get_filename().c_str());
6568 if (jwin_file_select_ex(
6569 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6570 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6571 return D_CLOSE;
6572
6573 if (fileexists(replay_path))
6574 {
6575 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6576 NULL,NULL,"OK",NULL,13,27,lfont);
6577 return D_CLOSE;
6578 }
6579
6580 replay_save(replay_path);
6581 }
6582 else
6583 {
6584 replay_save();
6585 }
6586 }
6587 return D_O_K;
6588 }
6589
6590 static MENU replay_menu[] =
6591 {
6592 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6593 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6594 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6595 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6596 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6597 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6598
6599 { NULL, NULL, NULL, 0, NULL }
6600 };
6601
6602 static DIALOG credits_dlg[] =
6603 {
6604 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6605 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6606 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6607 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6608 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6609 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6610 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6611 };
6612
6613 9 static ListData dmap_list(dmaplist, &font);
6614
6615 static DIALOG goto_dlg[] =
6616 {
6617 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6618 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6619 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6620 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6621 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6622 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6623 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6624 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6625 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6626 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6627 };
6628
6629 int32_t onGoTo()
6630 {
6631 bool music = false;
6632 music = music;
6633 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6634
6635 goto_dlg[0].dp2=lfont;
6636 goto_dlg[4].d2=cheat_goto_dmap;
6637 goto_dlg[6].dp=cheat_goto_screen_str;
6638
6639 clear_keybuf();
6640
6641 if(is_large)
6642 large_dialog(goto_dlg);
6643
6644 if(zc_popup_dialog(goto_dlg,4)==1)
6645 {
6646 // dmap, screen
6647 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6648 };
6649
6650 return D_O_K;
6651 }
6652
6653 int32_t onGoToComplete()
6654 {
6655 if(!Playing)
6656 {
6657 return D_O_K;
6658 }
6659
6660 system_pal();
6661 music_pause();
6662 pause_all_sfx();
6663 show_mouse(screen);
6664 onGoTo();
6665 eat_buttons();
6666
6667 zc_readrawkey(KEY_ESC);
6668
6669 show_mouse(NULL);
6670 game_pal();
6671 music_resume();
6672 resume_all_sfx();
6673 return D_O_K;
6674 }
6675
6676 int32_t onCredits()
6677 {
6678 go();
6679
6680 BITMAP *win = create_bitmap_ex(8,222,110);
6681
6682 if(!win)
6683 return D_O_K;
6684
6685 int32_t c=0;
6686 int32_t l=0;
6687 int32_t ol=-1;
6688 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6689 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6690 PALETTE tmppal;
6691
6692 rti_gui.transparency_index = 1;
6693
6694 clear_to_color(win, rti_gui.transparency_index);
6695 draw_rle_sprite(win,rle,0,0);
6696 credits_dlg[0].dp2=lfont;
6697 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6698 credits_dlg[2].dp = win;
6699
6700 set_palette_range(black_palette,0,127,false);
6701
6702 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6703
6704 BITMAP* old_screen = screen;
6705 BITMAP* gui_bmp = zc_get_gui_bmp();
6706 ASSERT(gui_bmp);
6707 clear_to_color(gui_bmp, rti_gui.transparency_index);
6708 screen = gui_bmp;
6709
6710 while(update_dialog(p))
6711 {
6712 throttleFPS();
6713 ++c;
6714 l = zc_max((c>>1)-30,0);
6715
6716 if(l > rle->h)
6717 l = c = 0;
6718
6719 if(l > rle->h - 112)
6720 l = rle->h - 112;
6721
6722 clear_bitmap(win);
6723 draw_rle_sprite(win,rle,0,0-l);
6724
6725 if(c<=64)
6726 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6727
6728 set_palette_range(tmppal,0,127,false);
6729
6730 if(l!=ol)
6731 {
6732 scare_mouse();
6733 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6734 unscare_mouse();
6735 SCRFIX();
6736 ol=l;
6737 }
6738
6739 update_hw_screen();
6740 }
6741
6742 screen = old_screen;
6743 system_pal();
6744
6745 shutdown_dialog(p);
6746 destroy_bitmap(win);
6747 //comeback();
6748
6749 rti_gui.transparency_index = 0;
6750
6751 return D_O_K;
6752 }
6753
6754 const char *midilist(int32_t index, int32_t *list_size)
6755 {
6756 if(index<0)
6757 {
6758 *list_size=0;
6759
6760 for(int32_t i=0; i<MAXMIDIS; i++)
6761 if(tunes[i].data)
6762 ++(*list_size);
6763
6764 return NULL;
6765 }
6766
6767 int32_t i=0,m=0;
6768
6769 while(m<=index && i<=MAXMIDIS)
6770 {
6771 if(tunes[i].data)
6772 ++m;
6773
6774 ++i;
6775 }
6776
6777 --i;
6778
6779 if(i==MAXMIDIS && m<index)
6780 return "(null)";
6781
6782 return tunes[i].title;
6783 }
6784
6785 /* ------- MIDI info stuff -------- */
6786
6787 char *text;
6788 midi_info *zmi;
6789 bool dialog_running;
6790 bool listening;
6791
6792 void get_info(int32_t index);
6793
6794 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6795 {
6796 int32_t d2 = d->d2;
6797 int32_t ret = jwin_droplist_proc(msg,d,c);
6798
6799 if(d2!=d->d2)
6800 {
6801 get_info(d->d2);
6802 }
6803
6804 return ret;
6805 }
6806
6807 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6808 {
6809 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6810
6811 int32_t ret = jwin_button_proc(msg,d,c);
6812
6813 if(ret == D_CLOSE)
6814 {
6815 // get current midi index
6816 int32_t index = (d+(d->d1))->d2;
6817 int32_t i=0, m=0;
6818
6819 while(m<=index && i<=MAXMIDIS)
6820 {
6821 if(tunes[i].data)
6822 ++m;
6823
6824 ++i;
6825 }
6826
6827 --i;
6828 jukebox(i);
6829 listening = true;
6830 ret = D_O_K;
6831 }
6832
6833 return ret;
6834 }
6835
6836 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6837 {
6838 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6839
6840 int32_t ret = jwin_button_proc(msg,d,c);
6841
6842 if(ret == D_CLOSE)
6843 {
6844 // get current midi index
6845 int32_t index = (d+(d->d1))->d2;
6846 int32_t i=0, m=0;
6847
6848 while(m<=index && i<=MAXMIDIS)
6849 {
6850 if(tunes[i].data)
6851 ++m;
6852
6853 ++i;
6854 }
6855
6856 --i;
6857
6858 // get file name
6859
6860 int32_t sel=0;
6861 //struct ffblk f;
6862 char title[40] = "Save MIDI: ";
6863 char fname[2048];
6864 memset(fname,0,2048);
6865 static EXT_LIST list[] =
6866 {
6867 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6868 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6869 { NULL, NULL }
6870 };
6871
6872 strcpy(title+11, tunes[i].title);
6873 title[39] = '\0';
6874
6875 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6876 goto done;
6877
6878 if(exists(fname))
6879 {
6880 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6881 goto done;
6882 }
6883
6884 // save midi i
6885
6886 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6887 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6888
6889 done:
6890 chop_path(fname);
6891 ret = D_REDRAW;
6892 }
6893
6894 return ret;
6895 }
6896
6897 9 static ListData midi_list(midilist, &font);
6898
6899 static DIALOG midi_dlg[] =
6900 {
6901 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6902 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6903 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6904 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6905 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6906 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6907 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6908 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6909 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6910 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6911 };
6912
6913 void get_info(int32_t index)
6914 {
6915 int32_t i=0, m=0;
6916
6917 while(m<=index && i<=MAXMIDIS)
6918 {
6919 if(tunes[i].data)
6920 ++m;
6921
6922 ++i;
6923 }
6924
6925 --i;
6926
6927 if(i==MAXMIDIS && m<index)
6928 strcpy(text,"(null)");
6929 else
6930 {
6931 get_midi_info((MIDI*)tunes[i].data,zmi);
6932 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6933 }
6934
6935 midi_dlg[0].dp2=lfont;
6936 midi_dlg[3].dp = text;
6937 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6938 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6939
6940 if(dialog_running)
6941 {
6942 scare_mouse();
6943 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6944 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6945 unscare_mouse();
6946 }
6947 }
6948
6949 int32_t onMIDICredits()
6950 {
6951 text = (char*)malloc(4096);
6952 zmi = (midi_info*)malloc(sizeof(midi_info));
6953
6954 if(!text || !zmi)
6955 {
6956 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6957 return D_O_K;
6958 }
6959
6960 bool do_pause_midi = midi_pos >= 0 && currmidi;
6961 auto restore_midi = currmidi;
6962 if(do_pause_midi)
6963 {
6964 paused_midi_pos = midi_pos;
6965 stop_midi();
6966 midi_paused=true;
6967 midi_suspended = midissuspHALTED;
6968 }
6969
6970 midi_dlg[0].dp2=lfont;
6971 midi_dlg[2].d1 = 0;
6972 midi_dlg[2].d2 = 0;
6973 midi_dlg[4].flags = D_EXIT;
6974 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6975
6976 listening = false;
6977 dialog_running=false;
6978 get_info(0);
6979
6980 dialog_running=true;
6981
6982 if(is_large)
6983 large_dialog(midi_dlg);
6984
6985 zc_popup_dialog(midi_dlg,0);
6986 dialog_running=false;
6987
6988 if(listening)
6989 music_stop();
6990
6991 if(do_pause_midi)
6992 {
6993 midi_suspended = midissuspRESUME;
6994 currmidi = restore_midi;
6995 midi_pos = paused_midi_pos;
6996 }
6997
6998 if(text) free(text);
6999 if(zmi) free(zmi);
7000 return D_O_K;
7001 }
7002
7003 int32_t onAbout()
7004 {
7005 char buf1[80]={0};
7006 std::ostringstream oss;
7007 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
7008 oss << buf1 << '\n';
7009 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
7010 oss << buf1 << '\n';
7011 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
7012 oss << buf1 << '\n';
7013 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
7014 oss << buf1 << '\n';
7015
7016 InfoDialog("About ZC", oss.str()).show();
7017 return D_O_K;
7018 }
7019
7020 int32_t onQuest()
7021 {
7022 char fname[100];
7023 strcpy(fname, get_filename(qstpath));
7024 quest_dlg[0].dp2=lfont;
7025 quest_dlg[1].dp = fname;
7026
7027 if(QHeader.quest_number==0)
7028 sprintf(str_a,"Custom");
7029 else
7030 sprintf(str_a,"%d",QHeader.quest_number);
7031
7032 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
7033
7034 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
7035 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
7036
7037 if(is_large)
7038 large_dialog(quest_dlg);
7039
7040 zc_popup_dialog(quest_dlg, 0);
7041 return D_O_K;
7042 }
7043
7044 void call_vidmode_dlg();
7045 int32_t onVidMode()
7046 {
7047 call_vidmode_dlg();
7048 return D_O_K;
7049 }
7050
7051 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
7052 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
7053 //Added an extra statement, so that if the key is cleared to 0, the cleared
7054 //keybinding status need not be unique. -Z ( 1st April, 2019 )
7055
7056 void load_ukeys(int32_t* arr)
7057 {
7058 arr[ukey_a] = Akey;
7059 arr[ukey_b] = Bkey;
7060 arr[ukey_s] = Skey;
7061 arr[ukey_l] = Lkey;
7062 arr[ukey_r] = Rkey;
7063 arr[ukey_p] = Pkey;
7064 arr[ukey_ex1] = Exkey1;
7065 arr[ukey_ex2] = Exkey2;
7066 arr[ukey_ex3] = Exkey3;
7067 arr[ukey_ex4] = Exkey4;
7068 arr[ukey_du] = DUkey;
7069 arr[ukey_dd] = DDkey;
7070 arr[ukey_dl] = DLkey;
7071 arr[ukey_dr] = DRkey;
7072 arr[ukey_mod1a] = cheat_modifier_keys[0];
7073 arr[ukey_mod1b] = cheat_modifier_keys[1];
7074 arr[ukey_mod2a] = cheat_modifier_keys[2];
7075 arr[ukey_mod2b] = cheat_modifier_keys[3];
7076 };
7077
7078 static const char* ukey_names[] = {
7079 "A", "B", "Start", "L", "R", "Map",
7080 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
7081 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
7082 "Cheat Mod R1", "Cheat Mod R2",
7083 };
7084 std::string get_ukey_name(int32_t k)
7085 {
7086 if (k < num_ukey) return ukey_names[k];
7087 return "";
7088 }
7089
7090 int32_t onKeyboard()
7091 {
7092 int32_t a = Akey;
7093 int32_t b = Bkey;
7094 int32_t s = Skey;
7095 int32_t l = Lkey;
7096 int32_t r = Rkey;
7097 int32_t p = Pkey;
7098 int32_t ex1 = Exkey1;
7099 int32_t ex2 = Exkey2;
7100 int32_t ex3 = Exkey3;
7101 int32_t ex4 = Exkey4;
7102 int32_t du = DUkey;
7103 int32_t dd = DDkey;
7104 int32_t dl = DLkey;
7105 int32_t dr = DRkey;
7106 int32_t mod1a = cheat_modifier_keys[0];
7107 int32_t mod1b = cheat_modifier_keys[1];
7108 int32_t mod2a = cheat_modifier_keys[2];
7109 int32_t mod2b = cheat_modifier_keys[3];
7110 bool done=false;
7111 int32_t ret;
7112
7113 keyboard_control_dlg[0].dp2=lfont;
7114
7115 if(is_large)
7116 large_dialog(keyboard_control_dlg);
7117
7118 while(!done)
7119 {
7120 ret = zc_popup_dialog(keyboard_control_dlg,3);
7121
7122 if(ret==3) // OK
7123 {
7124 int32_t ukeys[num_ukey];
7125 load_ukeys(ukeys);
7126 std::vector<std::string> uniqueError;
7127 for(int32_t q = 0; q < num_ukey; ++q)
7128 {
7129 for(int32_t p = q+1; p < num_ukey; ++p)
7130 {
7131 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7132 {
7133 char buf[64];
7134 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7135 std::string str(buf);
7136 uniqueError.push_back(str);
7137 }
7138 }
7139 }
7140 if(uniqueError.size() == 0)
7141 done = true;
7142 else
7143 {
7144 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7145 box_out("Cannot have duplicate keybinds!"); box_eol();
7146 for(std::vector<std::string>::iterator it = uniqueError.begin();
7147 it != uniqueError.end(); ++it)
7148 {
7149 box_out((*it).c_str()); box_eol();
7150 }
7151 box_end(true);
7152 }
7153 /* Old uniqueness check
7154 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7155 bool unique = true;
7156 addToHash(A,unique,keyhash);
7157 addToHash(B,unique,keyhash);
7158 addToHash(S,unique,keyhash);
7159 addToHash(L,unique,keyhash);
7160 addToHash(R,unique,keyhash);
7161 addToHash(P,unique,keyhash);
7162 addToHash(DU,unique,keyhash);
7163 addToHash(DD,unique,keyhash);
7164 addToHash(DL,unique,keyhash);
7165 addToHash(DR,unique,keyhash);
7166
7167 if(keyhash->find(Exkey1) == keyhash->end())
7168 {
7169 (*keyhash)[Exkey1]=true;
7170 }
7171 else
7172 {
7173 if ( Exkey1 != 0 ) unique = false;
7174 }
7175
7176 if(keyhash->find(Exkey2) == keyhash->end())
7177 {
7178 (*keyhash)[Exkey2]=true;
7179 }
7180 else
7181 {
7182 if ( Exkey2 != 0 ) unique = false;
7183 }
7184
7185 if(keyhash->find(Exkey3) == keyhash->end())
7186 {
7187 (*keyhash)[Exkey3]=true;
7188 }
7189 else
7190 {
7191 if ( Exkey3 != 0 ) unique = false;
7192 }
7193
7194 if(keyhash->find(Exkey4) == keyhash->end())
7195 {
7196 (*keyhash)[Exkey4]=true;
7197 }
7198 else
7199 {
7200 if ( Exkey4 != 0 )unique = false;
7201 }
7202 //modifier keys
7203 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7204 {
7205 (*keyhash)[cheat_modifier_keys[0]]=true;
7206 }
7207 else
7208 {
7209 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7210 }
7211 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7212 {
7213 (*keyhash)[cheat_modifier_keys[1]]=true;
7214 }
7215 else
7216 {
7217 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7218 }
7219 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7220 {
7221 (*keyhash)[cheat_modifier_keys[2]]=true;
7222 }
7223 else
7224 {
7225 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7226 }
7227 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7228 {
7229 (*keyhash)[cheat_modifier_keys[3]]=true;
7230 }
7231 else
7232 {
7233 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7234 }
7235
7236 delete keyhash;
7237
7238 if(unique)
7239 done=true;
7240 else
7241 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7242 */
7243 }
7244 else // Cancel
7245 {
7246 Akey = a;
7247 Bkey = b;
7248 Skey = s;
7249 Lkey = l;
7250 Rkey = r;
7251 Pkey = p;
7252 Exkey1 = ex1;
7253 Exkey2 = ex2;
7254 Exkey3 = ex3;
7255 Exkey4 = ex4;
7256 DUkey = du;
7257 DDkey = dd;
7258 DLkey = dl;
7259 DRkey = dr;
7260 cheat_modifier_keys[0] = mod1a;
7261 cheat_modifier_keys[1] = mod1b;
7262 cheat_modifier_keys[2] = mod2a;
7263 cheat_modifier_keys[3] = mod2b;
7264
7265 done=true;
7266 }
7267
7268 rest(1);
7269 }
7270
7271 save_game_configs();
7272 return D_O_K;
7273 }
7274
7275 int32_t onGamepad()
7276 {
7277 int32_t a = Abtn;
7278 int32_t b = Bbtn;
7279 int32_t s = Sbtn;
7280 int32_t l = Lbtn;
7281 int32_t r = Rbtn;
7282 int32_t m = Mbtn;
7283 int32_t p = Pbtn;
7284 int32_t ex1 = Exbtn1;
7285 int32_t ex2 = Exbtn2;
7286 int32_t ex3 = Exbtn3;
7287 int32_t ex4 = Exbtn4;
7288 int32_t up = DUbtn;
7289 int32_t down = DDbtn;
7290 int32_t left = DLbtn;
7291 int32_t right = DRbtn;
7292
7293 gamepad_dlg[0].dp2=lfont;
7294 if(analog_movement)
7295 gamepad_dlg[56].flags|=D_SELECTED;
7296 else
7297 gamepad_dlg[56].flags&=~D_SELECTED;
7298
7299 if(is_large)
7300 large_dialog(gamepad_dlg);
7301
7302 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7303
7304 if(ret == 4) //OK
7305 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7306 else //Cancel
7307 {
7308 Abtn = a;
7309 Bbtn = b;
7310 Sbtn = s;
7311 Lbtn = l;
7312 Rbtn = r;
7313 Mbtn = m;
7314 Pbtn = p;
7315 Exbtn1 = ex1;
7316 Exbtn2 = ex2;
7317 Exbtn3 = ex3;
7318 Exbtn4 = ex4;
7319 DUbtn = up;
7320 DDbtn = down;
7321 DLbtn = left;
7322 DRbtn = right;
7323 }
7324
7325 save_game_configs();
7326 return D_O_K;
7327 }
7328
7329 int32_t onSound()
7330 {
7331 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7332 {
7333 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7334 }
7335 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7336 {
7337 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7338 }
7339 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7340 {
7341 emusic_volume = (int32_t)FFCore.usr_music_volume;
7342 }
7343 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7344 {
7345 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7346 }
7347 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7348 {
7349 pan_style = (int32_t)FFCore.usr_panstyle;
7350 }
7351
7352 int32_t m = midi_volume;
7353 int32_t d = digi_volume;
7354 int32_t e = emusic_volume;
7355 int32_t b = zcmusic_bufsz;
7356 int32_t s = sfx_volume;
7357 int32_t p = pan_style;
7358 pan_style = vbound(pan_style,0,3);
7359
7360 sound_dlg[0].dp2=lfont;
7361
7362 if(is_large)
7363 large_dialog(sound_dlg);
7364
7365 midi_dp[1] = sound_dlg[6].x;
7366 midi_dp[2] = sound_dlg[6].y;
7367 digi_dp[1] = sound_dlg[7].x;
7368 digi_dp[2] = sound_dlg[7].y;
7369 emus_dp[1] = sound_dlg[8].x;
7370 emus_dp[2] = sound_dlg[8].y;
7371 buf_dp[1] = sound_dlg[9].x;
7372 buf_dp[2] = sound_dlg[9].y;
7373 sfx_dp[1] = sound_dlg[10].x;
7374 sfx_dp[2] = sound_dlg[10].y;
7375 pan_dp[1] = sound_dlg[11].x;
7376 pan_dp[2] = sound_dlg[11].y;
7377 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7378 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7379 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7380 sound_dlg[18].d2 = zcmusic_bufsz;
7381 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7382 sound_dlg[20].d2 = pan_style;
7383
7384 int32_t ret = zc_popup_dialog(sound_dlg,1);
7385
7386 if(ret==2)
7387 {
7388 master_volume(digi_volume,midi_volume);
7389
7390 for(int32_t i=0; i<WAV_COUNT; ++i)
7391 {
7392 //allegro assertion fails when passing in -1 as voice -DD
7393 if(sfx_voice[i] > 0)
7394 voice_set_volume(sfx_voice[i], sfx_volume);
7395 }
7396 }
7397 else
7398 {
7399 midi_volume = m;
7400 digi_volume = d;
7401 emusic_volume = e;
7402 zcmusic_bufsz = b;
7403 sfx_volume = s;
7404 pan_style = p;
7405 }
7406
7407 save_game_configs();
7408 return D_O_K;
7409 }
7410
7411 int32_t queding(char const* s1, char const* s2, char const* s3)
7412 {
7413 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7414 }
7415
7416 int32_t onQuit()
7417 {
7418 if(Playing)
7419 {
7420 int32_t ret=0;
7421
7422 if(get_bit(quest_rules, qr_NOCONTINUE))
7423 {
7424 if(standalone_mode)
7425 {
7426 ret=queding("End current game?",
7427 "The continue screen is disabled; the game",
7428 "will be reloaded from the last save.");
7429 }
7430 else
7431 {
7432 ret=queding("End current game?",
7433 "The continue screen is disabled. You will",
7434 "be returned to the file select screen.");
7435 }
7436 }
7437 else
7438 ret=queding("End current game?",NULL,NULL);
7439
7440 if(ret==1)
7441 {
7442 disableClickToFreeze=false;
7443 Quit=qQUIT;
7444
7445 // Trying to evade a door repair charge?
7446 if(repaircharge)
7447 {
7448 game->change_drupy(-repaircharge);
7449 repaircharge=0;
7450 }
7451
7452 return D_CLOSE;
7453 }
7454 }
7455
7456 return D_O_K;
7457 }
7458
7459 int32_t onTryQuitMenu()
7460 {
7461 return onTryQuit(true);
7462 }
7463
7464 int32_t onTryQuit(bool inMenu)
7465 {
7466 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7467 {
7468 if(get_bit(quest_rules,qr_OLD_F6))
7469 {
7470 if(inMenu) onQuit();
7471 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7472 }
7473 else
7474 {
7475 disableClickToFreeze=false;
7476 GameFlags |= GAMEFLAG_TRYQUIT;
7477 }
7478 return D_CLOSE;
7479 }
7480
7481 return D_O_K;
7482 }
7483
7484 int32_t onReset()
7485 {
7486 if(queding(" Reset system? ",NULL,NULL)==1)
7487 {
7488 disableClickToFreeze=false;
7489 Quit=qRESET;
7490 replay_quit();
7491 return D_CLOSE;
7492 }
7493
7494 return D_O_K;
7495 }
7496
7497 int32_t onExit()
7498 {
7499 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7500 {
7501 Quit=qEXIT;
7502 return D_CLOSE;
7503 }
7504
7505 return D_O_K;
7506 }
7507
7508 int32_t onTitle_NES()
7509 {
7510 title_version=0;
7511 return D_O_K;
7512 }
7513 int32_t onTitle_DX()
7514 {
7515 title_version=1;
7516 return D_O_K;
7517 }
7518 int32_t onTitle_25()
7519 {
7520 title_version=2;
7521 return D_O_K;
7522 }
7523
7524 int32_t onDebug()
7525 {
7526 if(debug_enabled)
7527 set_debug(!get_debug());
7528 save_game_configs();
7529 return D_O_K;
7530 }
7531
7532 int32_t onHeartBeep()
7533 {
7534 heart_beep=!heart_beep;
7535 save_game_configs();
7536 return D_O_K;
7537 }
7538
7539 int32_t onSaveIndicator()
7540 {
7541 use_save_indicator=!use_save_indicator;
7542 save_game_configs();
7543 return D_O_K;
7544 }
7545
7546 int32_t onEpilepsy()
7547 {
7548 if(jwin_alert3(
7549 "Epilepsy Flash Reduction",
7550 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7551 "Disabling this will restore standard flash and wavy behaviour.",
7552 "Proceed?",
7553 "&Yes",
7554 "&No",
7555 NULL,
7556 'y',
7557 'n',
7558 0,
7559 lfont) == 1)
7560 {
7561 if ( epilepsyFlashReduction ) epilepsyFlashReduction = 0;
7562 else epilepsyFlashReduction = 1;
7563 set_config_int("zeldadx","checked_epilepsy",1);
7564 save_game_configs();
7565 }
7566 return D_O_K;
7567 }
7568
7569 int32_t onTriforce()
7570 {
7571 for(int32_t i=0; i<MAXINITTABS; ++i)
7572 {
7573 init_tabs[i].flags&=~D_SELECTED;
7574 }
7575
7576 init_tabs[3].flags=D_SELECTED;
7577 return onCheatConsole();
7578 /*triforce_dlg[0].dp2=lfont;
7579 for(int32_t i=1; i<=8; i++)
7580 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7581
7582 if(zc_popup_dialog (triforce_dlg,-1)==9)
7583 {
7584 for(int32_t i=1; i<=8; i++)
7585 {
7586 game->lvlitems[i] &= ~liTRIFORCE;
7587 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7588 }
7589 }
7590 return D_O_K;*/
7591 }
7592
7593 bool rc = false;
7594 /*
7595 int32_t onEquipment()
7596 {
7597 for (int32_t i=0; i<MAXINITTABS; ++i)
7598 {
7599 init_tabs[i].flags&=~D_SELECTED;
7600 }
7601 init_tabs[0].flags=D_SELECTED;
7602 return onCheatConsole();
7603 }
7604 */
7605
7606 int32_t onItems()
7607 {
7608 for(int32_t i=0; i<MAXINITTABS; ++i)
7609 {
7610 init_tabs[i].flags&=~D_SELECTED;
7611 }
7612
7613 init_tabs[1].flags=D_SELECTED;
7614 return onCheatConsole();
7615 }
7616
7617 static DIALOG getnum_dlg[] =
7618 {
7619 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7620 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7621 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7622 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7623 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7624 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7625 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7626 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7627 };
7628
7629 int32_t getnumber(const char *prompt,int32_t initialval)
7630 {
7631 char buf[20];
7632 sprintf(buf,"%d",initialval);
7633 getnum_dlg[0].dp=(void *)prompt;
7634 getnum_dlg[0].dp2=lfont;
7635 getnum_dlg[2].dp=buf;
7636
7637 if(is_large)
7638 large_dialog(getnum_dlg);
7639
7640 if(zc_popup_dialog(getnum_dlg,2)==3)
7641 return atoi(buf);
7642
7643 return initialval;
7644 }
7645
7646 int32_t onLife()
7647 {
7648 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7649 cheats_enqueue(Cheat::Life, value);
7650 return D_O_K;
7651 }
7652
7653 int32_t onHeartC()
7654 {
7655 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7656 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7657 cheats_enqueue(Cheat::MaxLife, max_life);
7658 cheats_enqueue(Cheat::Life, life);
7659 return D_O_K;
7660 }
7661
7662 int32_t onMagicC()
7663 {
7664 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7665 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7666 cheats_enqueue(Cheat::MaxMagic, max_magic);
7667 cheats_enqueue(Cheat::Magic, magic);
7668 return D_O_K;
7669 }
7670
7671 int32_t onRupies()
7672 {
7673 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7674 cheats_enqueue(Cheat::Rupies, value);
7675 return D_O_K;
7676 }
7677
7678 int32_t onMaxBombs()
7679 {
7680 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7681 cheats_enqueue(Cheat::MaxBombs, value);
7682 cheats_enqueue(Cheat::Bombs, value);
7683 return D_O_K;
7684 }
7685
7686 int32_t onRefillLife()
7687 {
7688 cheats_enqueue(Cheat::Life, game->get_maxlife());
7689 return D_O_K;
7690 }
7691 int32_t onRefillMagic()
7692 {
7693 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7694 return D_O_K;
7695 }
7696 int32_t onClock()
7697 {
7698 cheats_enqueue(Cheat::Clock);
7699 return D_O_K;
7700 }
7701
7702 int32_t onQstPath()
7703 {
7704 char path[2048];
7705
7706 chop_path(qstdir);
7707 strcpy(path,qstdir);
7708
7709 go();
7710
7711 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7712 {
7713 chop_path(path);
7714 fix_filename_case(path);
7715 fix_filename_slashes(path);
7716 strcpy(qstdir,path);
7717 strcpy(qstpath,qstdir);
7718 }
7719
7720 comeback();
7721 return D_O_K;
7722 }
7723
7724 #include "dialog/cheat_dialog.h"
7725 int32_t onCheat()
7726 {
7727 call_setcheat_dialog();
7728 game->set_cheat(maxcheat);
7729 if(cheat) game->did_cheat(true);
7730 return D_O_K;
7731 }
7732
7733 int32_t onCheatRupies()
7734 {
7735 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7736 return D_O_K;
7737 }
7738
7739 int32_t onCheatArrows()
7740 {
7741 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7742 return D_O_K;
7743 }
7744
7745 int32_t onCheatBombs()
7746 {
7747 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7748 return D_O_K;
7749 }
7750
7751 // *** screen saver
7752
7753 445220 int32_t after_time()
7754 {
7755
1/2
✓ Branch 0 taken 445220 times.
✗ Branch 1 not taken.
445220 if(ss_enable == 0)
7756 return INT_MAX;
7757
7758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 445220 times.
445220 if(ss_after <= 0)
7759 return 5 * 60;
7760
7761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 445220 times.
445220 if(ss_after <= 3)
7762 return ss_after * 15 * 60;
7763
7764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 445220 times.
445220 if(ss_after <= 13)
7765 return (ss_after - 3) * 60 * 60;
7766
7767 445220 return MAX_IDLE + 1;
7768 445220 }
7769
7770 static const char *after_str[15] =
7771 {
7772 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7773 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7774 "Never"
7775 };
7776
7777 const char *after_list(int32_t index, int32_t *list_size)
7778 {
7779 if(index < 0)
7780 {
7781 *list_size = 15;
7782 return NULL;
7783 }
7784
7785 return after_str[index];
7786 }
7787
7788 9 static ListData after__list(after_list, &font);
7789
7790 static DIALOG scrsaver_dlg[] =
7791 {
7792 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7793 9 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7794 9 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7795 9 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7796 9 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7797 9 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7798 9 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7799 9 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7800 9 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7801 9 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7802 9 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7803 9 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7804 9 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7805 9 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7806 };
7807
7808 int32_t onScreenSaver()
7809 {
7810 scrsaver_dlg[0].dp2=lfont;
7811 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = ss_after;
7812 scrsaver_dlg[6].d2 = ss_speed;
7813 scrsaver_dlg[7].d2 = ss_density;
7814
7815 if(is_large)
7816 large_dialog(scrsaver_dlg);
7817
7818 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7819
7820 if(ret == 8 || ret == 9)
7821 {
7822 ss_after = scrsaver_dlg[5].d1;
7823 ss_speed = scrsaver_dlg[6].d2;
7824 ss_density = scrsaver_dlg[7].d2;
7825 }
7826
7827 if(ret == 9)
7828 // preview Screen Saver
7829 {
7830 clear_keybuf();
7831 scare_mouse();
7832 Matrix(ss_speed, ss_density, 30);
7833 system_pal();
7834 unscare_mouse();
7835 }
7836
7837 return D_O_K;
7838 }
7839
7840 /***** Menus *****/
7841
7842 static MENU game_menu[] =
7843 {
7844 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7845 { (char *)"", NULL, NULL, 0, NULL },
7846 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7847 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7848 { (char *)"", NULL, NULL, 0, NULL },
7849 #ifdef __EMSCRIPTEN__
7850 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7851 #elif defined(ALLEGRO_MACOSX)
7852 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7853 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7854 #else
7855 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7856 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7857 #endif
7858 { NULL, NULL, NULL, 0, NULL }
7859 };
7860
7861 static MENU title_menu[] =
7862 {
7863 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7864 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7865 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7866 { NULL, NULL, NULL, 0, NULL }
7867 };
7868
7869 static MENU snapshot_format_menu[] =
7870 {
7871 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7872 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7873 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7874 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7875 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7876 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7877 { NULL, NULL, NULL, 0, NULL }
7878 };
7879
7880 static MENU controls_menu[] =
7881 {
7882 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7883 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7884 { NULL, NULL, NULL, 0, NULL }
7885 };
7886
7887 static MENU name_entry_mode_menu[] =
7888 {
7889 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7890 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7891 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7892 { NULL, NULL, NULL, 0, NULL }
7893 };
7894
7895 static void set_controls_menu_active()
7896 {
7897
7898 }
7899
7900 static MENU settings_menu[] =
7901 {
7902 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7903 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7904 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7905 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7906 { (char *)"", NULL, NULL, 0, NULL },
7907 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7908 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7909 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7910 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7911 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7912 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7913 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7914 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7915 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7916 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7917 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7918 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7919 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7920 { (char *)"", NULL, NULL, 0, NULL },
7921 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7922 { (char *)"", NULL, NULL, 0, NULL },
7923 { NULL, NULL, NULL, 0, NULL }
7924 };
7925
7926
7927 static MENU misc_menu[] =
7928 {
7929 { (char *)"&About...", onAbout, NULL, 0, NULL },
7930 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7931 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7932 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7933 { (char *)"", NULL, NULL, 0, NULL },
7934 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7935 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7936 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7937 { (char *)"", NULL, NULL, 0, NULL },
7938 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7939 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7940 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7941 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7942 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7943 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7944 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7945 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7946
7947 { NULL, NULL, NULL, 0, NULL }
7948 };
7949
7950 static MENU refill_menu[] =
7951 {
7952 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7953 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7954 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7955 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7956 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7957 { NULL, NULL, NULL, 0, NULL }
7958 };
7959
7960 static MENU show_menu[] =
7961 {
7962 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7963 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7964 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7965 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7966 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7967 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7968 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7969 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7970 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7971 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7972 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7973 { (char *)"", NULL, NULL, 0, NULL },
7974 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7975 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7976 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7977 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7978 { NULL, NULL, NULL, 0, NULL }
7979 };
7980
7981 static MENU cheat_menu[] =
7982 {
7983 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7984 { (char *)"", NULL, NULL, 0, NULL },
7985 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7986 { (char *)"", NULL, NULL, 0, NULL },
7987 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7988 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7989 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7990 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7991 { (char *)"", NULL, NULL, 0, NULL },
7992 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7993 { (char *)"", NULL, NULL, 0, NULL },
7994 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7995 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7996 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7997 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7998 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7999 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
8000 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
8001 { NULL, NULL, NULL, 0, NULL }
8002 };
8003
8004 static MENU fixes_menu[] =
8005 {
8006 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
8007 { NULL, NULL, NULL, 0, NULL }
8008 };
8009
8010 #if DEVLEVEL > 0
8011 int32_t devLogging();
8012 int32_t devDebug();
8013 int32_t devTimestmp();
8014 #if DEVLEVEL > 1
8015 int32_t setCheat();
8016 #endif //DEVLEVEL > 1
8017 enum
8018 {
8019 dv_log,
8020 // dv_dbg,
8021 dv_tmpstmp,
8022 #if DEVLEVEL > 1
8023 dv_nil,
8024 dv_setcheat,
8025 #endif //DEVLEVEL > 1
8026 dv_max
8027 };
8028 static MENU dev_menu[] =
8029 {
8030 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
8031 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
8032 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
8033 #if DEVLEVEL > 1
8034 { (char *)"", NULL, NULL, 0, NULL },
8035 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
8036 #endif //DEVLEVEL > 1
8037 { NULL, NULL, NULL, 0, NULL }
8038 };
8039 int32_t devLogging()
8040 {
8041 dev_logging = !dev_logging;
8042 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
8043 return D_O_K;
8044 }
8045 // int32_t devDebug()
8046 // {
8047 // dev_debug = !dev_debug;
8048 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
8049 // return D_O_K;
8050 // }
8051 int32_t devTimestmp()
8052 {
8053 dev_timestmp = !dev_timestmp;
8054 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
8055 return D_O_K;
8056 }
8057 #if DEVLEVEL > 1
8058 int32_t setCheat()
8059 {
8060 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
8061 return D_O_K;
8062 }
8063 #endif //DEVLEVEL > 1
8064 #endif //DEVLEVEL > 0
8065
8066 MENU the_player_menu[] =
8067 {
8068 { (char *)"&Game", NULL, game_menu, 0, NULL },
8069 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8070 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
8071 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8072 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8073 #if DEVLEVEL > 0
8074 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8075 #endif
8076 { NULL, NULL, NULL, 0, NULL }
8077 };
8078
8079 MENU the_player_menu2[] =
8080 {
8081 { (char *)"&Game", NULL, game_menu, 0, NULL },
8082 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8083 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8084 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8085 #if DEVLEVEL > 0
8086 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8087 #endif
8088 { NULL, NULL, NULL, 0, NULL }
8089 };
8090
8091 int32_t onMIDIPatch()
8092 {
8093 if(jwin_alert3(
8094 "Toggle Windows MIDI Fix",
8095 "This action will change whether ZC Player auto-restarts a MIDI at its",
8096 "last index if you move ZC Player out of focus, then back into focus.",
8097 "Proceed?",
8098 "&Yes",
8099 "&No",
8100 NULL,
8101 'y',
8102 'n',
8103 0,
8104 lfont) == 1)
8105 {
8106 if (midi_patch_fix) midi_patch_fix = 0;
8107
8108 else midi_patch_fix = 1;
8109
8110 }
8111 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8112 save_game_configs();
8113 return D_O_K;
8114 }
8115
8116 int32_t onKeyboardEntry()
8117 {
8118 NameEntryMode=0;
8119 return D_O_K;
8120 }
8121
8122 int32_t onLetterGridEntry()
8123 {
8124 NameEntryMode=1;
8125 return D_O_K;
8126 }
8127
8128 int32_t onExtLetterGridEntry()
8129 {
8130 NameEntryMode=2;
8131 return D_O_K;
8132 }
8133
8134 static BITMAP* oldscreen;
8135 int32_t onFullscreenMenu()
8136 {
8137 // super hacks
8138 screen = oldscreen;
8139 if (onFullscreen() == D_REDRAW)
8140 {
8141 oldscreen = screen;
8142 }
8143 screen = menu_bmp;
8144 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8145 return D_O_K;
8146 }
8147
8148 9 void fix_menu()
8149 {
8150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9 times.
9 if(!debug_enabled)
8151 9 settings_menu[18].text = NULL;
8152 9 }
8153
8154 static DIALOG system_dlg[] =
8155 {
8156 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8157 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8158 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8159 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8160 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8161 #ifndef ALLEGRO_MACOSX
8162 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8163 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8164 #else
8165 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8166 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8167 #endif
8168 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8169 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8170 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8171 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8172 };
8173
8174 static DIALOG system_dlg2[] =
8175 {
8176 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8177 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8178 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8179 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8180 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8181 #ifndef ALLEGRO_MACOSX
8182 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8183 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8184 #else
8185 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8186 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8187 #endif
8188 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8189 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8190 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8191 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8192 };
8193
8194 void reset_snapshot_format_menu()
8195 {
8196 for(int32_t i=0; i<ssfmtMAX; ++i)
8197 {
8198 snapshot_format_menu[i].flags=0;
8199 }
8200 }
8201
8202 int32_t onSetSnapshotFormat()
8203 {
8204 switch(active_menu->text[1])
8205 {
8206 case 'B': //"&BMP"
8207 SnapshotFormat=0;
8208 break;
8209
8210 case 'G': //"&GIF"
8211 SnapshotFormat=1;
8212 break;
8213
8214 case 'J': //"&JPG"
8215 SnapshotFormat=2;
8216 break;
8217
8218 case 'P': //"&PNG"
8219 SnapshotFormat=3;
8220 break;
8221
8222 case 'C': //"PC&X"
8223 SnapshotFormat=4;
8224 break;
8225
8226 case 'T': //"&TGA"
8227 SnapshotFormat=5;
8228 break;
8229
8230 case 'L': //"&LBM"
8231 SnapshotFormat=6;
8232 break;
8233 }
8234
8235 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8236 return D_O_K;
8237 }
8238
8239
8240 10 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8241 {
8242 PALETTE tmp;
8243
8244
2/2
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 10 times.
2570 for(int32_t i=0; i<256; i++)
8245 {
8246 2560 tmp[i].r=r;
8247 2560 tmp[i].g=g;
8248 2560 tmp[i].b=b;
8249 2560 }
8250
8251 10 fade_interpolate(src,tmp,dest,pos,from,to);
8252 10 }
8253
8254 10 void system_pal()
8255 {
8256 10 is_sys_pal = true;
8257 static PALETTE pal;
8258 10 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8259
8260 // set up the grayscale palette
8261
2/2
✓ Branch 0 taken 640 times.
✓ Branch 1 taken 10 times.
650 for(int32_t i=128; i<192; i++)
8262 {
8263 640 pal[i].r = i-128;
8264 640 pal[i].g = i-128;
8265 640 pal[i].b = i-128;
8266 640 }
8267 10 load_colorset(gui_colorset, pal);
8268
8269 10 color_layer(pal, pal, 24,16,16, 28, 128,191);
8270
8271
2/2
✓ Branch 0 taken 1280 times.
✓ Branch 1 taken 10 times.
1290 for(int32_t i=0; i<256; i+=2)
8272 {
8273 1280 int32_t v = (i>>3)+2;
8274 1280 int32_t c = (i>>3)+192;
8275 1280 pal[c] = _RGB(v,v,v+(v>>1));
8276 /*
8277 if(i<240)
8278 {
8279 _allegro_hline(tmp_scr,0,i,319,c);
8280 _allegro_hline(tmp_scr,0,i+1,319,c);
8281 }
8282 */
8283 1280 }
8284
8285 // draw the vertical screen gradient
8286
2/2
✓ Branch 0 taken 2400 times.
✓ Branch 1 taken 10 times.
2410 for(int32_t i=0; i<240; ++i)
8287 {
8288 2400 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8289 2400 }
8290
8291 /*
8292 palrstart= 10*63/255; palrend=166*63/255;
8293 palgstart= 36*63/255; palgend=202*63/255;
8294 palbstart=106*63/255; palbend=240*63/255;
8295 paldivs=32;
8296 for(int32_t i=0; i<paldivs; i++)
8297 {
8298 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8299 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8300 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8301 }
8302 */
8303 10 BITMAP *panorama = create_bitmap_ex(8,256,224);
8304 int32_t ts_height, ts_start;
8305
8306
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
10 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8307 {
8308 clear_to_color(panorama,0);
8309 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8310 ts_height=224-passive_subscreen_height;
8311 ts_start=28;
8312 }
8313 else
8314 {
8315 10 blit(framebuf,panorama,0,0,0,0,256,224);
8316 10 ts_height=224;
8317 10 ts_start=0;
8318 }
8319
8320 // gray scale the current frame
8321
2/2
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 10 times.
2250 for(int32_t y=0; y<ts_height; y++)
8322 {
8323
2/2
✓ Branch 0 taken 573440 times.
✓ Branch 1 taken 2240 times.
575680 for(int32_t x=0; x<256; x++)
8324 {
8325 573440 int32_t c = panorama->line[y+ts_start][x];
8326
2/2
✓ Branch 0 taken 572959 times.
✓ Branch 1 taken 481 times.
573440 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8327 573440 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8328 573440 }
8329 2240 }
8330
8331 10 destroy_bitmap(panorama);
8332
8333 // display everything
8334 10 vsync();
8335 10 hw_palette = &pal;
8336 10 update_hw_pal = true;
8337
8338 // sys_pal = pal;
8339 10 memcpy(sys_pal,pal,sizeof(pal));
8340 10 }
8341
8342 void system_pal2()
8343 {
8344 is_sys_pal = true;
8345 static PALETTE RAMpal2;
8346 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8347
8348 /* Windows 2000 colors
8349 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8350 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8351 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8352 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8353 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8354 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8355 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8356 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8357
8358 byte palrstart= 10*63/255, palrend=166*63/255,
8359 palgstart= 36*63/255, palgend=202*63/255,
8360 palbstart=106*63/255, palbend=240*63/255,
8361 paldivs=7;
8362 for(int32_t i=0; i<paldivs; i++)
8363 {
8364 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8365 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8366 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8367 }
8368 */
8369
8370 /* Windows 98 colors
8371 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8372 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8373 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8374 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8375 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8376 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8377 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8378 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8379
8380 byte palrstart= 0*63/255, palrend=166*63/255,
8381 palgstart= 0*63/255, palgend=202*63/255,
8382 palbstart=128*63/255, palbend=240*63/255,
8383 paldivs=7;
8384 for(int32_t i=0; i<paldivs; i++)
8385 {
8386 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8387 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8388 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8389 }
8390 */
8391
8392 /* Windows 99 colors
8393 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8394 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8395 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8396 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8397 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8398 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8399 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8400 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8401 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8402
8403 byte palrstart= 0*63/255, palrend=166*63/255,
8404 palgstart= 0*63/255, palgend=202*63/255,
8405
8406 palbstart=128*63/255, palbend=240*63/255,
8407 paldivs=6;
8408 for(int32_t i=0; i<paldivs; i++)
8409 {
8410 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8411 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8412 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8413 }
8414 */
8415
8416
8417
8418 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8419 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8420 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8421 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8422 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8423 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8424 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8425 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8426 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8427
8428 byte palrstart= 0*63/255, palrend=166*63/255,
8429 palgstart= 0*63/255, palgend=202*63/255,
8430 palbstart=128*63/255, palbend=240*63/255,
8431 paldivs=6;
8432
8433 for(int32_t i=0; i<paldivs; i++)
8434 {
8435 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8436 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8437 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8438 }
8439
8440 gui_bg_color=jwin_pal[jcBOX];
8441 gui_fg_color=jwin_pal[jcBOXFG];
8442
8443 jwin_set_colors(jwin_pal);
8444
8445
8446 // set up the new palette
8447 for(int32_t i=128; i<192; i++)
8448 {
8449 RAMpal2[i].r = i-128;
8450 RAMpal2[i].g = i-128;
8451 RAMpal2[i].b = i-128;
8452 }
8453
8454 /*
8455 for(int32_t i=0; i<64; i++)
8456 {
8457 RAMpal2[128+i] = _RGB(i,i,i)1));
8458 }
8459 */
8460
8461 /*
8462
8463 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8464 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8465 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8466 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8467 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8468 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8469 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8470
8471 gui_fg_color=vc(14);
8472 gui_bg_color=vc(1);
8473
8474 jwin_set_colors(jwin_pal);
8475 */
8476
8477 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8478
8479 // set up the colors for the vertical screen gradient
8480 for(int32_t i=0; i<256; i+=2)
8481 {
8482 int32_t v = (i>>3)+2;
8483 int32_t c = (i>>3)+192;
8484 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8485
8486 /*
8487 if(i<240)
8488 {
8489 _allegro_hline(tmp_scr,0,i,319,c);
8490 _allegro_hline(tmp_scr,0,i+1,319,c);
8491 }
8492 */
8493 }
8494
8495 // hw_palette = &RAMpal;
8496 // update_hw_pal = true;
8497
8498 for(int32_t i=0; i<240; ++i)
8499 {
8500 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8501 }
8502
8503 /*
8504 byte palrstart= 10*63/255, palrend=166*63/255,
8505 palgstart= 36*63/255, palgend=202*63/255,
8506 palbstart=106*63/255, palbend=240*63/255,
8507 paldivs=32;
8508 for(int32_t i=0; i<paldivs; i++)
8509 {
8510 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8511 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8512 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8513 }
8514 */
8515 BITMAP *panorama = create_bitmap_ex(8,256,224);
8516 int32_t ts_height, ts_start;
8517
8518 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8519 {
8520 clear_to_color(panorama,0);
8521 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8522 ts_height=224-passive_subscreen_height;
8523 ts_start=28;
8524 }
8525 else
8526 {
8527 blit(framebuf,panorama,0,0,0,0,256,224);
8528 ts_height=224;
8529 ts_start=0;
8530 }
8531
8532 // gray scale the current frame
8533 for(int32_t y=0; y<ts_height; y++)
8534 {
8535 for(int32_t x=0; x<256; x++)
8536 {
8537 int32_t c = panorama->line[y+ts_start][x];
8538 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8539 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8540 }
8541 }
8542
8543 destroy_bitmap(panorama);
8544
8545 // display everything
8546 vsync();
8547 hw_palette = &RAMpal2;
8548 update_hw_pal = true;
8549
8550 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8551
8552 // sys_pal = pal;
8553 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8554 }
8555
8556 static uint32_t entered_sys_pal = 0;
8557 1 void enter_sys_pal()
8558 {
8559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(is_sys_pal)
8560 {
8561 if(entered_sys_pal)
8562 ++entered_sys_pal;
8563 return;
8564 }
8565 1 system_pal();
8566 1 ++entered_sys_pal;
8567 1 }
8568 1 void exit_sys_pal()
8569 {
8570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(entered_sys_pal)
8571 {
8572
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!--entered_sys_pal)
8573 {
8574 1 game_pal();
8575 1 }
8576 1 }
8577 1 }
8578
8579 void switch_out_callback()
8580 {
8581 if (pause_in_background)
8582 {
8583 callback_switchin = 3;
8584 return;
8585 }
8586
8587 #ifdef _WIN32
8588 if(midi_patch_fix==0 || currmidi==-1)
8589 return;
8590
8591
8592 paused_midi_pos = midi_pos;
8593 zc_stop_midi();
8594 midi_paused=true;
8595 midi_suspended = midissuspHALTED;
8596 #endif
8597 }
8598
8599 void switch_in_callback()
8600 {
8601 zc_update_builtin_font();
8602
8603 if(pause_in_background)
8604 {
8605 return;
8606 }
8607
8608 #ifdef _WIN32
8609 if(midi_patch_fix==0 || currmidi==-1)
8610 return;
8611
8612 else
8613 {
8614 callback_switchin = 1;
8615 midi_suspended = midissuspRESUME;
8616 }
8617 #endif
8618 }
8619
8620 37 void game_pal()
8621 {
8622 37 is_sys_pal = false;
8623 37 entered_sys_pal = 0;
8624 37 clear_to_color(screen,BLACK);
8625 37 hw_palette = &RAMpal;
8626 37 update_hw_pal = true;
8627 37 }
8628
8629 static char bar_str[] = "";
8630
8631 1 void music_pause()
8632 {
8633 //al_pause_duh(tmplayer);
8634 1 zcmusic_pause(zcmusic, ZCM_PAUSE);
8635 1 zc_midi_pause();
8636 1 midi_paused=true;
8637 1 }
8638
8639 void music_resume()
8640 {
8641 //al_resume_duh(tmplayer);
8642 zcmusic_pause(zcmusic, ZCM_RESUME);
8643 zc_midi_resume();
8644 midi_paused=false;
8645 }
8646
8647 350 void music_stop()
8648 {
8649 //al_stop_duh(tmplayer);
8650 //unload_duh(tmusic);
8651 //tmusic=NULL;
8652 //tmplayer=NULL;
8653 350 zcmusic_stop(zcmusic);
8654 350 zcmusic_unload_file(zcmusic);
8655 350 zc_stop_midi();
8656 350 midi_paused=false;
8657 350 currmidi=-1;
8658 350 }
8659
8660 void System()
8661 {
8662 mouse_down=gui_mouse_b();
8663 music_pause();
8664 pause_all_sfx();
8665 MenuOpen = true;
8666 system_pal();
8667 // FONT *oldfont=font;
8668 // font=tfont;
8669
8670 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8671 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8672
8673 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8674 #if DEVLEVEL > 1
8675 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8676 #endif
8677 game_menu[3].flags =
8678 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8679 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8680 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8681 clear_keybuf();
8682 show_mouse(screen);
8683
8684 DIALOG_PLAYER *p;
8685
8686 clear_bitmap(menu_bmp);
8687 oldscreen = screen;
8688 screen = menu_bmp;
8689
8690 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8691 {
8692 p = init_dialog(system_dlg2,-1);
8693 }
8694 else
8695 {
8696 p = init_dialog(system_dlg,-1);
8697 }
8698
8699 // drop the menu on startup if menu button pressed
8700 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8701 simulate_keypress(KEY_G << 8);
8702
8703 do
8704 {
8705 if(close_button_quit)
8706 {
8707 close_button_quit = false;
8708 f_Quit(qEXIT);
8709 if(Quit) break;
8710 }
8711 rest(17);
8712
8713 if(mouse_down && !gui_mouse_b())
8714 mouse_down=0;
8715
8716 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8717 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8718 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8719
8720 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8721 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8722 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8723 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8724 settings_menu[8].flags = NESquit?D_SELECTED:0;
8725 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8726 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8727 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8728 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8729 settings_menu[13].flags = volkeys?D_SELECTED:0;
8730 //Epilepsy Prevention
8731 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8732
8733 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8734 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8735 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8736
8737 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8738 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8739
8740 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8741 cheat_menu[0].flags = 0;
8742 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8743 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8744 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8745 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8746 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8747 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8748 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8749 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8750 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8751
8752 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8753 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8754 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8755 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8756 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8757 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8758 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8759 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8760 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8761 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8762 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8763 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8764 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8765 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8766 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8767
8768 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8769 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8770
8771 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8772 (char *)"Disable recording new saves" :
8773 (char *)"Enable recording new saves";
8774 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8775 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8776 (char *)"Stop recording" :
8777 (char *)"Stop replaying";
8778 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8779
8780 reset_snapshot_format_menu();
8781 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8782
8783 if(debug_enabled)
8784 {
8785 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8786 }
8787
8788 if(gui_mouse_b() && !mouse_down)
8789 break;
8790
8791 // press menu to drop the menu
8792 if(rMbtn())
8793 simulate_keypress(KEY_G << 8);
8794
8795 if(input_idle(true) > after_time())
8796 // run Screeen Saver
8797 {
8798 // Screen saver enabled for now.
8799 clear_keybuf();
8800 scare_mouse();
8801 Matrix(ss_speed, ss_density, 0);
8802 system_pal();
8803 unscare_mouse();
8804 broadcast_dialog_message(MSG_DRAW, 0);
8805 }
8806
8807 update_hw_screen();
8808 }
8809 while(update_dialog(p));
8810
8811 screen = oldscreen;
8812
8813 // font=oldfont;
8814 mouse_down=gui_mouse_b();
8815 shutdown_dialog(p);
8816 show_mouse(NULL);
8817 MenuOpen = false;
8818 if(Quit)
8819 {
8820 kill_sfx();
8821 music_stop();
8822 update_hw_screen();
8823 }
8824 else
8825 {
8826 game_pal();
8827 music_resume();
8828 resume_all_sfx();
8829
8830 if(rc)
8831 ringcolor(false);
8832 }
8833
8834 eat_buttons();
8835
8836 rc=false;
8837 clear_keybuf();
8838 // text_mode(0);
8839 }
8840
8841 9 void fix_dialogs()
8842 {
8843 9 jwin_center_dialog(about_dlg);
8844 9 jwin_center_dialog(gamepad_dlg);
8845 9 jwin_center_dialog(credits_dlg);
8846 9 jwin_center_dialog(gamemode_dlg);
8847 9 jwin_center_dialog(getnum_dlg);
8848 9 jwin_center_dialog(goto_dlg);
8849 9 jwin_center_dialog(keyboard_control_dlg);
8850 9 jwin_center_dialog(midi_dlg);
8851 9 jwin_center_dialog(quest_dlg);
8852 9 jwin_center_dialog(scrsaver_dlg);
8853 9 jwin_center_dialog(sound_dlg);
8854 9 jwin_center_dialog(triforce_dlg);
8855
8856 // digi_dp[1] += scrx;
8857 // digi_dp[2] += scry;
8858 // midi_dp[1] += scrx;
8859 // midi_dp[2] += scry;
8860 // pan_dp[1] += scrx;
8861 // pan_dp[2] += scry;
8862 // emus_dp[1] += scrx;
8863 // emus_dp[2] += scry;
8864 // buf_dp[1] += scrx;
8865 // buf_dp[2] += scry;
8866 // sfx_dp[1] += scrx;
8867 // sfx_dp[2] += scry;
8868 9 }
8869
8870 /*****************************/
8871 /**** Custom Sound System ****/
8872 /*****************************/
8873
8874 95 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8875 {
8876
4/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 43 times.
✓ Branch 3 taken 52 times.
95 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8877 }
8878
8879 // Run an NSF, or a MIDI if the NSF is missing somehow.
8880 12 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8881 {
8882 12 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8883
8884 // Found it
8885
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(newzcmusic!=NULL)
8886 {
8887 12 zcmusic_stop(zcmusic);
8888 12 zcmusic_unload_file(zcmusic);
8889 12 zc_stop_midi();
8890
8891 12 zcmusic=newzcmusic;
8892 12 zcmusic_play(zcmusic, emusic_volume);
8893
8894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(track>0)
8895 12 zcmusic_change_track(zcmusic,track);
8896
8897 12 return true;
8898 }
8899
8900 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8901 else if(midi>-1000)
8902 jukebox(midi);
8903
8904 return false;
8905 12 }
8906
8907 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8908 {
8909 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8910 // Found it
8911 if(newzcmusic!=NULL)
8912 {
8913 zcmusic_stop(zcmusic);
8914 zcmusic_unload_file(zcmusic);
8915 zc_stop_midi();
8916
8917 zcmusic=newzcmusic;
8918 zcmusic_play(zcmusic, emusic_volume);
8919
8920 if(track>0)
8921 zcmusic_change_track(zcmusic,track);
8922
8923 return true;
8924 }
8925
8926 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8927 else if(midi>-1000)
8928 jukebox(midi);
8929
8930 return false;
8931 }
8932
8933 int32_t get_zcmusicpos()
8934 {
8935 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8936 return debugtracething;
8937 return 0;
8938 }
8939
8940 void set_zcmusicpos(int32_t position)
8941 {
8942 zcmusic_set_curpos(zcmusic, position);
8943 }
8944
8945 void set_zcmusicspeed(int32_t speed)
8946 {
8947 int32_t newspeed = vbound(speed, 0, 10000);
8948 zcmusic_set_speed(zcmusic, newspeed);
8949 }
8950
8951 43 void jukebox(int32_t index,int32_t loop)
8952 {
8953 43 music_stop();
8954
8955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(index<0) index=MAXMIDIS-1;
8956
8957
1/2
✓ Branch 0 taken 43 times.
✗ Branch 1 not taken.
43 if(index>=MAXMIDIS) index=0;
8958
8959 43 music_stop();
8960
8961 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8962 // stuck notes when a song stops. This fixes it.
8963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 if(strcmp(midi_driver->name, "DIGMID")==0)
8964 zc_set_volume(0, 0);
8965
8966 43 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8967 43 zc_play_midi((MIDI*)tunes[index].data,loop);
8968
8969
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 9 times.
43 if(tunes[index].start>0)
8970 9 zc_midi_seek(tunes[index].start);
8971
8972 43 midi_loop_start = tunes[index].loop_start;
8973 43 midi_loop_end = tunes[index].loop_end;
8974
8975 43 currmidi=index;
8976 43 master_volume(digi_volume,midi_volume);
8977 43 midi_paused=false;
8978 43 }
8979
8980 245 void jukebox(int32_t index)
8981 {
8982
1/2
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
245 if(index<0) index=MAXMIDIS-1;
8983
8984
1/2
✓ Branch 0 taken 245 times.
✗ Branch 1 not taken.
245 if(index>=MAXMIDIS) index=0;
8985
8986 // do nothing if it's already playing
8987
3/4
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 43 times.
✓ Branch 2 taken 202 times.
✗ Branch 3 not taken.
245 if(index==currmidi && midi_pos>=0)
8988 {
8989 202 midi_paused=false;
8990 202 return;
8991 }
8992
8993 43 jukebox(index,tunes[index].loop);
8994 245 }
8995
8996 714 void play_DmapMusic()
8997 {
8998 static char tfile[2048];
8999 static int32_t ttrack=0;
9000 714 bool domidi=false;
9001
9002
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 243 times.
714 if(DMaps[currdmap].tmusic[0]!=0)
9003 {
9004
3/4
✓ Branch 0 taken 385 times.
✓ Branch 1 taken 86 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 385 times.
856 if(zcmusic==NULL ||
9005
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
9006
1/2
✓ Branch 0 taken 385 times.
✗ Branch 1 not taken.
385 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
9007 {
9008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 if(zcmusic != NULL)
9009 {
9010 zcmusic_stop(zcmusic);
9011 zcmusic_unload_file(zcmusic);
9012 zcmusic = NULL;
9013 }
9014
9015 86 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
9016
9017
1/2
✓ Branch 0 taken 86 times.
✗ Branch 1 not taken.
86 if(zcmusic!=NULL)
9018 {
9019 86 zc_stop_midi();
9020 86 strcpy(tfile,DMaps[currdmap].tmusic);
9021 86 zcmusic_play(zcmusic, emusic_volume);
9022 86 int32_t temptracks=0;
9023 86 temptracks=zcmusic_get_tracks(zcmusic);
9024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 86 times.
86 temptracks=(temptracks<2)?1:temptracks;
9025 86 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
9026 86 zcmusic_change_track(zcmusic,ttrack);
9027 86 }
9028 else
9029 {
9030 tfile[0] = 0;
9031 domidi=true;
9032 }
9033 86 }
9034 471 }
9035 else
9036 {
9037 243 domidi=true;
9038 }
9039
9040
2/2
✓ Branch 0 taken 471 times.
✓ Branch 1 taken 243 times.
714 if(domidi)
9041 {
9042 243 int32_t m=DMaps[currdmap].midi;
9043
9044
3/4
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
243 switch(m)
9045 {
9046 case 1:
9047 80 jukebox(ZC_MIDI_OVERWORLD);
9048 80 break;
9049
9050 case 2:
9051 9 jukebox(ZC_MIDI_DUNGEON);
9052 9 break;
9053
9054 case 3:
9055 jukebox(ZC_MIDI_LEVEL9);
9056 break;
9057
9058 default:
9059
3/4
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147 times.
154 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9060 147 jukebox(m+MIDIOFFSET_DMAP);
9061 else
9062 7 music_stop();
9063 154 }
9064 243 }
9065 714 }
9066
9067 714 void playLevelMusic()
9068 {
9069 714 int32_t m=tmpscr->screen_midi;
9070
9071
1/6
✓ Branch 0 taken 714 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
714 switch(m)
9072 {
9073 case -2:
9074 music_stop();
9075 break;
9076
9077 case -1:
9078 714 play_DmapMusic();
9079 714 break;
9080
9081 case 1:
9082 jukebox(ZC_MIDI_OVERWORLD);
9083 break;
9084
9085 case 2:
9086 jukebox(ZC_MIDI_DUNGEON);
9087 break;
9088
9089 case 3:
9090 jukebox(ZC_MIDI_LEVEL9);
9091 break;
9092
9093 default:
9094 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9095 jukebox(m+MIDIOFFSET_MAPSCR);
9096 else
9097 music_stop();
9098 }
9099 714 }
9100
9101 52 void master_volume(int32_t dv,int32_t mv)
9102 {
9103
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 52 times.
✗ Branch 7 not taken.
52 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9104
9105
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 52 times.
✓ Branch 4 taken 52 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 52 times.
52 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9106
9107
5/6
✓ Branch 0 taken 41 times.
✓ Branch 1 taken 11 times.
✓ Branch 2 taken 52 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 41 times.
✓ Branch 5 taken 11 times.
52 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9108 52 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9109 52 }
9110
9111 /*****************/
9112 /***** SFX *****/
9113 /*****************/
9114
9115 // array of voices, one for each sfx sample in the data file
9116 // 0+ = voice #
9117 // -1 = voice not allocated
9118 9 void Z_init_sound()
9119 {
9120
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 9 times.
2313 for(int32_t i=0; i<WAV_COUNT; i++)
9121 2304 sfx_voice[i]=-1;
9122
9123
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 9 times.
72 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9124 63 tunes[i].data = (MIDI*)mididata[i].dat;
9125
9126
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 9 times.
2277 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9127 2268 tunes[ZC_MIDI_COUNT+j].data=NULL;
9128
9129 9 master_volume(digi_volume,midi_volume);
9130 9 }
9131
9132 // returns number of voices currently allocated
9133 int32_t sfx_count()
9134 {
9135 int32_t c=0;
9136
9137 for(int32_t i=0; i<WAV_COUNT; i++)
9138 if(sfx_voice[i]!=-1)
9139 ++c;
9140
9141 return c;
9142 }
9143
9144 // clean up finished samples
9145 435420 void sfx_cleanup()
9146 {
9147
2/2
✓ Branch 0 taken 111467520 times.
✓ Branch 1 taken 435420 times.
111902940 for(int32_t i=0; i<WAV_COUNT; i++)
9148
4/4
✓ Branch 0 taken 1556930 times.
✓ Branch 1 taken 109910590 times.
✓ Branch 2 taken 1554214 times.
✓ Branch 3 taken 2716 times.
111470236 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9149 {
9150 2716 deallocate_voice(sfx_voice[i]);
9151 2716 sfx_voice[i]=-1;
9152 2716 }
9153 435420 }
9154
9155 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9156 // if a voice is already allocated (and/or playing), then it just returns true
9157 // Returns true: voice is allocated
9158 // false: unsuccessful
9159 49779 bool sfx_init(int32_t index)
9160 {
9161 // check index
9162
3/4
✓ Branch 0 taken 46935 times.
✓ Branch 1 taken 2844 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 46935 times.
49779 if(index<=0 || index>=WAV_COUNT)
9163 2844 return false;
9164
9165
2/2
✓ Branch 0 taken 43190 times.
✓ Branch 1 taken 3745 times.
46935 if(sfx_voice[index]==-1)
9166 {
9167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3745 times.
3745 if(sfxdat)
9168 {
9169 if(index<Z35)
9170 {
9171 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9172 }
9173 else
9174 {
9175 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9176 }
9177 }
9178 else
9179 {
9180 3745 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9181 }
9182
9183 3745 voice_set_volume(sfx_voice[index], sfx_volume);
9184 3745 }
9185
9186 46935 return sfx_voice[index] != -1;
9187 49779 }
9188
9189 // plays an sfx sample
9190 33174 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9191 {
9192
2/2
✓ Branch 0 taken 31364 times.
✓ Branch 1 taken 1810 times.
33174 if(!sfx_init(index))
9193 1810 return;
9194
9195 31364 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9196 31364 voice_set_pan(sfx_voice[index],pan);
9197
9198 31364 int32_t pos = voice_get_position(sfx_voice[index]);
9199
9200
2/2
✓ Branch 0 taken 17368 times.
✓ Branch 1 taken 13996 times.
31364 if(restart) voice_set_position(sfx_voice[index],0);
9201
9202
2/2
✓ Branch 0 taken 17267 times.
✓ Branch 1 taken 14097 times.
31364 if(pos<=0)
9203 17267 voice_start(sfx_voice[index]);
9204 33174 }
9205
9206 // true if sfx is allocated
9207 1 bool sfx_allocated(int32_t index)
9208 {
9209
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 times.
1 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9210 }
9211
9212 // start it (in loop mode) if it's not already playing,
9213 // otherwise adjust it to play in loop mode -DD
9214 16605 void cont_sfx(int32_t index)
9215 {
9216
2/2
✓ Branch 0 taken 1034 times.
✓ Branch 1 taken 15571 times.
16605 if(!sfx_init(index))
9217 {
9218 1034 return;
9219 }
9220
9221
2/2
✓ Branch 0 taken 933 times.
✓ Branch 1 taken 14638 times.
15571 if(voice_get_position(sfx_voice[index])<=0)
9222 {
9223 933 voice_set_position(sfx_voice[index],0);
9224 933 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9225 933 voice_start(sfx_voice[index]);
9226 933 }
9227 else
9228 {
9229 14638 adjust_sfx(index, 128, true);
9230 }
9231 16605 }
9232
9233 // adjust parameters while playing
9234 14920 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9235 {
9236
5/6
✓ Branch 0 taken 14707 times.
✓ Branch 1 taken 213 times.
✓ Branch 2 taken 14707 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 14655 times.
✓ Branch 5 taken 52 times.
14920 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9237 265 return;
9238
9239 14655 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9240 14655 voice_set_pan(sfx_voice[index],pan);
9241 14920 }
9242
9243 // pauses a voice
9244 27 void pause_sfx(int32_t index)
9245 {
9246
3/6
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 27 times.
27 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9247 voice_stop(sfx_voice[index]);
9248 27 }
9249
9250 // resumes a voice
9251 13 void resume_sfx(int32_t index)
9252 {
9253
3/6
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 13 times.
13 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9254 voice_start(sfx_voice[index]);
9255 13 }
9256
9257 // pauses all active voices
9258 1 void pause_all_sfx()
9259 {
9260
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<WAV_COUNT; i++)
9261
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 2 times.
258 if(sfx_voice[i]!=-1)
9262 2 voice_stop(sfx_voice[i]);
9263 1 }
9264
9265 // resumes all paused voices
9266 void resume_all_sfx()
9267 {
9268 for(int32_t i=0; i<WAV_COUNT; i++)
9269 if(sfx_voice[i]!=-1)
9270 voice_start(sfx_voice[i]);
9271 }
9272
9273 // stops an sfx and deallocates the voice
9274 336277 void stop_sfx(int32_t index)
9275 {
9276
3/4
✓ Branch 0 taken 334996 times.
✓ Branch 1 taken 1281 times.
✓ Branch 2 taken 334996 times.
✗ Branch 3 not taken.
336277 if(index<=0 || index>=WAV_COUNT)
9277 1281 return;
9278
9279
2/2
✓ Branch 0 taken 729 times.
✓ Branch 1 taken 334267 times.
334996 if(sfx_voice[index]!=-1)
9280 {
9281 729 deallocate_voice(sfx_voice[index]);
9282 729 sfx_voice[index]=-1;
9283 729 }
9284 336277 }
9285
9286 // Stops SFX played by Hero's item of the given family
9287 4202 void stop_item_sfx(int32_t family)
9288 {
9289 4202 int32_t id=current_item_id(family);
9290
9291
2/2
✓ Branch 0 taken 4167 times.
✓ Branch 1 taken 35 times.
4202 if(id<0)
9292 4167 return;
9293
9294 35 stop_sfx(itemsbuf[id].usesound);
9295 4202 }
9296
9297 138 void kill_sfx()
9298 {
9299
2/2
✓ Branch 0 taken 35328 times.
✓ Branch 1 taken 138 times.
35466 for(int32_t i=0; i<WAV_COUNT; i++)
9300
2/2
✓ Branch 0 taken 35036 times.
✓ Branch 1 taken 292 times.
35620 if(sfx_voice[i]!=-1)
9301 {
9302 292 deallocate_voice(sfx_voice[i]);
9303 292 sfx_voice[i]=-1;
9304 292 }
9305 138 }
9306
9307 29468 int32_t pan(int32_t x)
9308 {
9309
1/4
✓ Branch 0 taken 29468 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
29468 switch(pan_style)
9310 {
9311 case 0:
9312 return 128;
9313
9314 case 1:
9315 29468 return vbound((x>>1)+68,0,255);
9316
9317 case 2:
9318 return vbound(((x*3)>>2)+36,0,255);
9319 }
9320
9321 return vbound(x,0,255);
9322 29468 }
9323
9324 /*******************************/
9325 /******* Input Handlers ********/
9326 /*******************************/
9327
9328 624110 bool joybtn(int32_t b)
9329 {
9330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 624110 times.
624110 if(b == 0)
9331 return false;
9332
9333 624110 return joy[joystick_index].button[b-1].b !=0;
9334 624110 }
9335
9336 const char* joybtn_name(int32_t b)
9337 {
9338 if(b == 0)
9339 return "";
9340
9341 return joy[joystick_index].button[b-1].name;
9342 }
9343
9344 int32_t next_press_key()
9345 {
9346 return readkey()>>8;
9347 }
9348
9349 int32_t next_press_btn()
9350 {
9351 clear_keybuf();
9352 /*bool b[joy[joystick_index].num_buttons+1];
9353
9354 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9355 b[i]=joybtn(i);*/
9356
9357 //first, we need to wait until they're pressing no buttons
9358 for(;;)
9359 {
9360 if(keypressed())
9361 {
9362 switch(readkey()>>8)
9363 {
9364 case KEY_ESC:
9365 return -1;
9366
9367 case KEY_SPACE:
9368 return 0;
9369 }
9370 }
9371
9372 poll_joystick();
9373 bool done = true;
9374
9375 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9376 {
9377 if(joybtn(i)) done = false;
9378 }
9379
9380 if(done) break;
9381 rest(1);
9382 }
9383
9384 //now, we need to wait for them to press any button
9385 for(;;)
9386 {
9387 if(keypressed())
9388 {
9389 switch(readkey()>>8)
9390 {
9391 case KEY_ESC:
9392 return -1;
9393
9394 case KEY_SPACE:
9395 return 0;
9396 }
9397 }
9398
9399 poll_joystick();
9400
9401 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9402 {
9403 if(joybtn(i)) return i;
9404 }
9405 rest(1);
9406 }
9407 }
9408
9409 static bool rButton(bool(proc)(),bool &flag)
9410 {
9411 if(!proc())
9412 {
9413 flag=false;
9414 }
9415 else if(!flag)
9416 {
9417 flag=true;
9418 return true;
9419 }
9420
9421 return false;
9422 }
9423
9424 8454228 static bool rButton(bool &btn, bool &flag)
9425 {
9426
2/2
✓ Branch 0 taken 343816 times.
✓ Branch 1 taken 8110412 times.
8454228 if(!btn)
9427 {
9428 8110412 flag=false;
9429 8110412 }
9430
2/2
✓ Branch 0 taken 16326 times.
✓ Branch 1 taken 327490 times.
343816 else if(!flag)
9431 {
9432 16326 flag=true;
9433 16326 return true;
9434 }
9435
9436 8437902 return false;
9437 8454228 }
9438 619 static bool rButtonPeek(bool btn, bool flag)
9439 {
9440
2/2
✓ Branch 0 taken 583 times.
✓ Branch 1 taken 36 times.
619 if(!btn)
9441 {
9442 583 return false;
9443 }
9444
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
36 else if(!flag)
9445 {
9446 9 return true;
9447 }
9448
9449 27 return false;
9450 619 }
9451
9452 // Updated only by keyboard/gamepad.
9453 // If in replay mode, this is set directly by the replay system.
9454 // This should never be read from directly - use control_state instead.
9455 bool raw_control_state[ZC_CONTROL_STATES]=
9456 {
9457 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9458 };
9459
9460 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9461 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9462 // lasts until the next call to load_control_state.
9463 bool control_state[ZC_CONTROL_STATES]=
9464 {
9465 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9466 };
9467
9468 bool disable_control[ZC_CONTROL_STATES]=
9469 {
9470 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9471 };
9472
9473 bool drunk_toggle_state[11]=
9474 {
9475 false, false, false, false, false, false, false, false, false, false, false
9476 };
9477
9478 bool disabledKeys[127]=
9479 {
9480 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9481 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9482 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9483 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9484 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9485 false,false,false,false,false,false,false
9486 };
9487
9488 bool KeyInput[127]=
9489 {
9490 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9491 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9492 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9493 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9494 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9495 false,false,false,false,false,false,false
9496 };
9497
9498 bool KeyPress[127]=
9499 {
9500 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9501 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9502 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9503 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9504 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9505 false,false,false,false,false,false,false
9506 };
9507
9508 bool key_current_frame[127];
9509 bool key_previous_frame[127];
9510
9511 static bool key_system[127];
9512 static bool key_system_previous[127];
9513 static bool key_system_press[127];
9514
9515 bool button_press[ZC_CONTROL_STATES] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
9516 bool button_hold[ZC_CONTROL_STATES] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
9517
9518 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9519 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9520 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9521 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9522 #define STICK_PRECISION 56 //define your own sensitivity
9523
9524 338679 void load_control_state()
9525 {
9526
1/2
✓ Branch 0 taken 338679 times.
✗ Branch 1 not taken.
338679 if (!replay_is_replaying())
9527 {
9528 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9529 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9530 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9531 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9532 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9533 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9534 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9535 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9536 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9537 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9538 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9539 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9540 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9541 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9542
9543 if(num_joysticks != 0)
9544 {
9545 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9546 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9547 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9548 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9549 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9550 }
9551 else
9552 {
9553 raw_control_state[14] = false;
9554 raw_control_state[15] = false;
9555 raw_control_state[16] = false;
9556 raw_control_state[17] = false;
9557 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9558 }
9559 }
9560
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 338677 times.
338679 if (replay_is_active())
9561 {
9562
2/2
✓ Branch 0 taken 300655 times.
✓ Branch 1 taken 38022 times.
338677 if (replay_get_version() < 3)
9563 300655 replay_poll();
9564
3/4
✓ Branch 0 taken 38022 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9443 times.
✓ Branch 3 taken 28579 times.
38022 else if (replay_is_replaying() && replay_get_version() < 6)
9565 28579 replay_peek_input();
9566 338677 }
9567
9568 // Some test replay files were made before a serious input bug was fixed, so instead
9569 // of re-doing them or tossing them out, just check for that zplay version.
9570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 338675 times.
338679 bool botched_input = replay_is_replaying() && replay_get_version() == 1;
9571
2/2
✓ Branch 0 taken 338675 times.
✓ Branch 1 taken 6096150 times.
6434825 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9572 {
9573 6096150 control_state[i] = raw_control_state[i];
9574
4/4
✓ Branch 0 taken 3901950 times.
✓ Branch 1 taken 2194200 times.
✓ Branch 2 taken 220960 times.
✓ Branch 3 taken 3680990 times.
6096150 if(!botched_input && !control_state[i])
9575 3680990 down_control_states[i] = false;
9576 6096150 }
9577
9578 338675 button_press[0]=rButton(control_state[0],button_hold[0]);
9579 338675 button_press[1]=rButton(control_state[1],button_hold[1]);
9580 338675 button_press[2]=rButton(control_state[2],button_hold[2]);
9581 338675 button_press[3]=rButton(control_state[3],button_hold[3]);
9582 338675 button_press[4]=rButton(control_state[4],button_hold[4]);
9583 338675 button_press[5]=rButton(control_state[5],button_hold[5]);
9584 338675 button_press[6]=rButton(control_state[6],button_hold[6]);
9585 338675 button_press[7]=rButton(control_state[7],button_hold[7]);
9586 338675 button_press[8]=rButton(control_state[8],button_hold[8]);
9587 338675 button_press[9]=rButton(control_state[9],button_hold[9]);
9588 338675 button_press[10]=rButton(control_state[10],button_hold[10]);
9589 338675 button_press[11]=rButton(control_state[11],button_hold[11]);
9590 338675 button_press[12]=rButton(control_state[12],button_hold[12]);
9591 338675 button_press[13]=rButton(control_state[13],button_hold[13]);
9592 338675 button_press[14]=rButton(control_state[14],button_hold[14]);
9593 338675 button_press[15]=rButton(control_state[15],button_hold[15]);
9594 338675 button_press[16]=rButton(control_state[16],button_hold[16]);
9595 338675 button_press[17]=rButton(control_state[17],button_hold[17]);
9596 338675 }
9597
9598 // Returns true if any game key is pressed. This is needed because keypressed()
9599 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9600 1446852 bool zc_key_pressed()
9601 //may also need to use zc_getrawkey
9602 {
9603
7/10
✓ Branch 0 taken 1118283 times.
✓ Branch 1 taken 328569 times.
✓ Branch 2 taken 328569 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 328569 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 270873 times.
✓ Branch 7 taken 270873 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 61499 times.
1508351 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9604
4/6
✓ Branch 0 taken 270873 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 270873 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 187829 times.
✓ Branch 5 taken 187829 times.
270873 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9605
4/6
✓ Branch 0 taken 187829 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 187829 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 90346 times.
✓ Branch 5 taken 90346 times.
187829 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9606
4/6
✓ Branch 0 taken 90346 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 90346 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68419 times.
✓ Branch 5 taken 68419 times.
90346 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9607
1/2
✓ Branch 0 taken 68419 times.
✗ Branch 1 not taken.
68419 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9608
3/4
✓ Branch 0 taken 63366 times.
✓ Branch 1 taken 5053 times.
✓ Branch 2 taken 63366 times.
✗ Branch 3 not taken.
68419 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9609
3/4
✓ Branch 0 taken 61752 times.
✓ Branch 1 taken 1614 times.
✓ Branch 2 taken 61752 times.
✗ Branch 3 not taken.
63366 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9610
3/4
✓ Branch 0 taken 61579 times.
✓ Branch 1 taken 173 times.
✓ Branch 2 taken 61579 times.
✗ Branch 3 not taken.
61752 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9611
3/4
✓ Branch 0 taken 61499 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 61499 times.
✗ Branch 3 not taken.
61579 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9612
2/4
✓ Branch 0 taken 61499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61499 times.
✗ Branch 3 not taken.
61499 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9613
2/4
✓ Branch 0 taken 61499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61499 times.
✗ Branch 3 not taken.
61499 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9614
2/4
✓ Branch 0 taken 61499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61499 times.
✗ Branch 3 not taken.
61499 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9615
2/4
✓ Branch 0 taken 61499 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 61499 times.
✗ Branch 3 not taken.
61499 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9616
1/2
✓ Branch 0 taken 61499 times.
✗ Branch 1 not taken.
61499 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9617 2620287 return true;
9618
9619 61499 return false;
9620 445220 }
9621
9622 6854801 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9623 {
9624 6854801 bool ret = false, drunkstate = false;
9625 6854801 bool* flag = &down_control_states[btn];
9626
2/7
✓ Branch 0 taken 6408948 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 445853 times.
6854801 switch(btn)
9627 {
9628 case btnF12:
9629 ret = zc_getkey(KEY_F12, ignoreDisable);
9630 eatEntirely = false;
9631 break;
9632 case btnF11:
9633 ret = zc_getkey(KEY_F11, ignoreDisable);
9634 eatEntirely = false;
9635 break;
9636 case btnF5:
9637 ret = zc_getkey(KEY_F5, ignoreDisable);
9638 eatEntirely = false;
9639 break;
9640 case btnQ:
9641 ret = zc_getkey(KEY_Q, ignoreDisable);
9642 eatEntirely = false;
9643 break;
9644 case btnI:
9645 ret = zc_getkey(KEY_I, ignoreDisable);
9646 eatEntirely = false;
9647 break;
9648 case btnM:
9649
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 445853 times.
445853 if(FFCore.kb_typing_mode) return false;
9650 445853 ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9651 445853 eatEntirely = false;
9652 445853 break;
9653 default: //control_state[] index
9654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6408948 times.
6408948 if(FFCore.kb_typing_mode) return false;
9655
5/6
✓ Branch 0 taken 6399316 times.
✓ Branch 1 taken 9632 times.
✓ Branch 2 taken 237289 times.
✓ Branch 3 taken 6162027 times.
✓ Branch 4 taken 237289 times.
✗ Branch 5 not taken.
6408948 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9656
2/2
✓ Branch 0 taken 339952 times.
✓ Branch 1 taken 6068996 times.
6408948 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9657
4/4
✓ Branch 0 taken 5648003 times.
✓ Branch 1 taken 760945 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 760738 times.
7169893 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9658 6408948 }
9659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6854801 times.
6854801 assert(flag);
9660
2/2
✓ Branch 0 taken 4496104 times.
✓ Branch 1 taken 2358697 times.
6854801 if(press)
9661 {
9662
2/2
✓ Branch 0 taken 619 times.
✓ Branch 1 taken 2358078 times.
2358697 if(peek)
9663 619 ret = rButtonPeek(ret, *flag);
9664 2358078 else ret = rButton(ret, *flag);
9665 2358697 }
9666
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 6854801 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
6854801 if(eatEntirely && ret) control_state[btn] = false;
9667
3/4
✓ Branch 0 taken 5302815 times.
✓ Branch 1 taken 1551986 times.
✓ Branch 2 taken 5302815 times.
✗ Branch 3 not taken.
6854801 if(drunk && drunkstate) ret = !ret;
9668 6854801 return ret;
9669 6854801 }
9670
9671 8056 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9672 {
9673 8056 byte ret = 0;
9674
2/2
✓ Branch 0 taken 7437 times.
✓ Branch 1 taken 619 times.
8056 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9675
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9676
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9677
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9678
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9679
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9680
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9681
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9682 8056 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9683 }
9684
9685 byte checkIntBtnVal(byte intbtn, byte vals)
9686 {
9687 return intbtn&vals;
9688 }
9689
9690 67476 bool Up()
9691 {
9692 67476 return getInput(btnUp);
9693 }
9694 1183 bool Down()
9695 {
9696 1183 return getInput(btnDown);
9697 }
9698 2736 bool Left()
9699 {
9700 2736 return getInput(btnLeft);
9701 }
9702 3555 bool Right()
9703 {
9704 3555 return getInput(btnRight);
9705 }
9706 3778 bool cAbtn()
9707 {
9708 3778 return getInput(btnA);
9709 }
9710 21067 bool cBbtn()
9711 {
9712 21067 return getInput(btnB);
9713 }
9714 bool cSbtn()
9715 {
9716 return getInput(btnS);
9717 }
9718 bool cLbtn()
9719 {
9720 return getInput(btnL);
9721 }
9722 bool cRbtn()
9723 {
9724 return getInput(btnR);
9725 }
9726 bool cPbtn()
9727 {
9728 return getInput(btnP);
9729 }
9730 bool cEx1btn()
9731 {
9732 return getInput(btnEx1);
9733 }
9734 bool cEx2btn()
9735 {
9736 return getInput(btnEx2);
9737 }
9738 bool cEx3btn()
9739 {
9740 return getInput(btnEx3);
9741 }
9742 bool cEx4btn()
9743 {
9744 return getInput(btnEx4);
9745 }
9746 bool AxisUp()
9747 {
9748 return getInput(btnAxisUp);
9749 }
9750 bool AxisDown()
9751 {
9752 return getInput(btnAxisDown);
9753 }
9754 bool AxisLeft()
9755 {
9756 return getInput(btnAxisLeft);
9757 }
9758 bool AxisRight()
9759 {
9760 return getInput(btnAxisRight);
9761 }
9762
9763 bool cMbtn()
9764 {
9765 return getInput(btnM);
9766 }
9767 bool cF12()
9768 {
9769 return getInput(btnF12);
9770 }
9771 bool cF11()
9772 {
9773 return getInput(btnF11);
9774 }
9775 bool cF5()
9776 {
9777 return getInput(btnF5);
9778 }
9779 bool cQ()
9780 {
9781 return getInput(btnQ);
9782 }
9783 bool cI()
9784 {
9785 return getInput(btnI);
9786 }
9787
9788 422 bool rUp()
9789 {
9790 422 return getInput(btnUp, true);
9791 }
9792 413 bool rDown()
9793 {
9794 413 return getInput(btnDown, true);
9795 }
9796 412 bool rLeft()
9797 {
9798 412 return getInput(btnLeft, true);
9799 }
9800 412 bool rRight()
9801 {
9802 412 return getInput(btnRight, true);
9803 }
9804 38 bool rAbtn()
9805 {
9806 38 return getInput(btnA, true);
9807 }
9808 460 bool rBbtn()
9809 {
9810 460 return getInput(btnB, true);
9811 }
9812 337893 bool rSbtn()
9813 {
9814 337893 return getInput(btnS, true);
9815 }
9816 445220 bool rMbtn()
9817 {
9818 445220 return getInput(btnM, true);
9819 }
9820 411 bool rLbtn()
9821 {
9822 411 return getInput(btnL, true);
9823 }
9824 411 bool rRbtn()
9825 {
9826 411 return getInput(btnR, true);
9827 }
9828 337236 bool rPbtn()
9829 {
9830 337236 return getInput(btnP, true);
9831 }
9832 bool rEx1btn()
9833 {
9834 return getInput(btnEx1, true);
9835 }
9836 bool rEx2btn()
9837 {
9838 return getInput(btnEx2, true);
9839 }
9840 411 bool rEx3btn()
9841 {
9842 411 return getInput(btnEx3, true);
9843 }
9844 411 bool rEx4btn()
9845 {
9846 411 return getInput(btnEx4, true);
9847 }
9848 bool rAxisUp()
9849 {
9850 return getInput(btnAxisUp, true);
9851 }
9852 bool rAxisDown()
9853 {
9854 return getInput(btnAxisDown, true);
9855 }
9856 bool rAxisLeft()
9857 {
9858 return getInput(btnAxisLeft, true);
9859 }
9860 bool rAxisRight()
9861 {
9862 return getInput(btnAxisRight, true);
9863 }
9864
9865 bool rF11()
9866 {
9867 return getInput(btnF11, true);
9868 }
9869 bool rQ()
9870 {
9871 return getInput(btnQ, true);
9872 }
9873 bool rI()
9874 {
9875 return getInput(btnI, true);
9876 }
9877
9878 892788 bool DrunkUp()
9879 {
9880 892788 return getInput(btnUp, false, true);
9881 }
9882 817813 bool DrunkDown()
9883 {
9884 817813 return getInput(btnDown, false, true);
9885 }
9886 521528 bool DrunkLeft()
9887 {
9888 521528 return getInput(btnLeft, false, true);
9889 }
9890 451229 bool DrunkRight()
9891 {
9892 451229 return getInput(btnRight, false, true);
9893 }
9894 383152 bool DrunkcAbtn()
9895 {
9896 383152 return getInput(btnA, false, true);
9897 }
9898 337561 bool DrunkcBbtn()
9899 {
9900 337561 return getInput(btnB, false, true);
9901 }
9902 337231 bool DrunkcEx1btn()
9903 {
9904 337231 return getInput(btnEx1, false, true);
9905 }
9906 337231 bool DrunkcEx2btn()
9907 {
9908 337231 return getInput(btnEx2, false, true);
9909 }
9910 bool DrunkcSbtn()
9911 {
9912 return getInput(btnS, false, true);
9913 }
9914 bool DrunkcMbtn()
9915 {
9916 return getInput(btnM, false, true);
9917 }
9918 bool DrunkcLbtn()
9919 {
9920 return getInput(btnL, false, true);
9921 }
9922 bool DrunkcRbtn()
9923 {
9924 return getInput(btnR, false, true);
9925 }
9926 bool DrunkcPbtn()
9927 {
9928 return getInput(btnP, false, true);
9929 }
9930
9931 bool DrunkrUp()
9932 {
9933 return getInput(btnUp, true, true);
9934 }
9935 bool DrunkrDown()
9936 {
9937 return getInput(btnDown, true, true);
9938 }
9939 bool DrunkrLeft()
9940 {
9941 return getInput(btnLeft, true, true);
9942 }
9943 bool DrunkrRight()
9944 {
9945 return getInput(btnRight, true, true);
9946 }
9947 274282 bool DrunkrAbtn()
9948 {
9949 274282 return getInput(btnA, true, true);
9950 }
9951 275017 bool DrunkrBbtn()
9952 {
9953 275017 return getInput(btnB, true, true);
9954 }
9955 bool DrunkrEx1btn()
9956 {
9957 return getInput(btnEx1, true, true);
9958 }
9959 bool DrunkrEx2btn()
9960 {
9961 return getInput(btnEx2, true, true);
9962 }
9963 bool DrunkrEx3btn()
9964 {
9965 return getInput(btnEx3, true, true);
9966 }
9967 bool DrunkrEx4btn()
9968 {
9969 return getInput(btnEx4, true, true);
9970 }
9971 bool DrunkrSbtn()
9972 {
9973 return getInput(btnS, true, true);
9974 }
9975 bool DrunkrMbtn()
9976 {
9977 return getInput(btnM, true, true);
9978 }
9979 337236 bool DrunkrLbtn()
9980 {
9981 337236 return getInput(btnL, true, true);
9982 }
9983 337128 bool DrunkrRbtn()
9984 {
9985 337128 return getInput(btnR, true, true);
9986 }
9987 bool DrunkrPbtn()
9988 {
9989 return getInput(btnP, true, true);
9990 }
9991
9992 633 void eat_buttons()
9993 {
9994 633 getInput(btnA, true, false, true);
9995 633 getInput(btnB, true, false, true);
9996 633 getInput(btnS, true, false, true);
9997 633 getInput(btnM, true, false, true);
9998 633 getInput(btnL, true, false, true);
9999 633 getInput(btnR, true, false, true);
10000 633 getInput(btnP, true, false, true);
10001 633 getInput(btnEx1, true, false, true);
10002 633 getInput(btnEx2, true, false, true);
10003 633 getInput(btnEx3, true, false, true);
10004 633 getInput(btnEx4, true, false, true);
10005 633 }
10006
10007 // Is true for the _first frame_ of a key press.
10008 // But! it is possible that a script manually sets the value of KeyPress,
10009 // in which case it will be restored to the "true" value based on `key_current_frame`
10010 // and `key_previous_frame` on the next frame.
10011 1 bool zc_readkey(int32_t k, bool ignoreDisable)
10012 {
10013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(ignoreDisable) return KeyPress[k];
10014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 switch(k)
10015 {
10016 case KEY_F7:
10017 case KEY_F8:
10018 case KEY_F9:
10019 return KeyPress[k];
10020
10021 default:
10022
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 return KeyPress[k] && !disabledKeys[k];
10023 }
10024 1 }
10025
10026 // Is true for _every frame_ a key is held down.
10027 // But! it is possible that a script manually sets the value of KeyInput,
10028 // in which case it will be restored to the "true" value based on `key_current_frame`
10029 // on the next frame.
10030 bool zc_getkey(int32_t k, bool ignoreDisable)
10031 {
10032 if(ignoreDisable) return KeyInput[k];
10033 switch(k)
10034 {
10035 case KEY_F7:
10036 case KEY_F8:
10037 case KEY_F9:
10038 return KeyInput[k];
10039
10040 default:
10041 return KeyInput[k] && !disabledKeys[k];
10042 }
10043 }
10044
10045 // Reads (and then clears) the current frame key state directly.
10046 // Scripts can also modify `key_current_frame`.
10047 111803 bool zc_readrawkey(int32_t k, bool ignoreDisable)
10048 {
10049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111803 times.
111803 if(zc_getrawkey(k, ignoreDisable))
10050 {
10051 _key[k]=key[k]=key_current_frame[k]=0;
10052 return true;
10053 }
10054 111803 _key[k]=key[k]=key_current_frame[k]=0;
10055 111803 return false;
10056 111803 }
10057
10058 // Reads the current frame key state directly.
10059 // Scripts can also modify `key_current_frame`.
10060 2443104 bool zc_getrawkey(int32_t k, bool ignoreDisable)
10061 {
10062
2/2
✓ Branch 0 taken 1886082 times.
✓ Branch 1 taken 557022 times.
2443104 if(ignoreDisable) return key_current_frame[k];
10063
2/2
✓ Branch 0 taken 111800 times.
✓ Branch 1 taken 445222 times.
557022 switch(k)
10064 {
10065 case KEY_F7:
10066 case KEY_F8:
10067 case KEY_F9:
10068 111800 return key_current_frame[k];
10069
10070 default:
10071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 445222 times.
445222 return key_current_frame[k] && !disabledKeys[k];
10072 }
10073 2443104 }
10074
10075 // Only used for a handful of keys, like tilde and Function keys.
10076 // This state is never read within the game.
10077 // It exists so that all keyboard input still functions during replay,
10078 // without inadvertently doing things like toggling throttling if the player
10079 // presses ~
10080 435420 bool zc_get_system_key(int32_t k)
10081 {
10082 435420 return key_system[k];
10083 }
10084
10085 // True for the _first_ frame of a key press.
10086 4897420 bool zc_read_system_key(int32_t k)
10087 {
10088 4897420 return key_system_press[k];
10089 }
10090
10091 56542940 bool is_system_key(int32_t k)
10092 {
10093
2/2
✓ Branch 0 taken 52535960 times.
✓ Branch 1 taken 4006980 times.
56542940 switch (k)
10094 {
10095 case KEY_BACKQUOTE:
10096 case KEY_CLOSEBRACE:
10097 case KEY_END:
10098 case KEY_HOME:
10099 case KEY_OPENBRACE:
10100 case KEY_PGDN:
10101 case KEY_PGUP:
10102 case KEY_TAB:
10103 case KEY_TILDE:
10104 4006980 return true;
10105 }
10106 52535960 return is_Fkey(k);
10107 56542940 }
10108
10109 445220 void update_system_keys()
10110 {
10111 445220 poll_keyboard();
10112
2/2
✓ Branch 0 taken 56542940 times.
✓ Branch 1 taken 445220 times.
56988160 for (int32_t q = 0; q < 127; ++q)
10113 {
10114
2/2
✓ Branch 0 taken 9349620 times.
✓ Branch 1 taken 47193320 times.
56542940 if (!is_system_key(q))
10115 47193320 continue;
10116
10117 9349620 key_system[q] = key[q];
10118
1/2
✓ Branch 0 taken 9349620 times.
✗ Branch 1 not taken.
9349620 key_system_press[q] = key_system[q] && !key_system_previous[q];
10119 9349620 key_system_previous[q] = key_system[q];
10120 9349620 }
10121 445220 }
10122
10123 435420 void update_keys()
10124 {
10125
1/2
✓ Branch 0 taken 435420 times.
✗ Branch 1 not taken.
435420 if (!replay_is_replaying())
10126 poll_keyboard();
10127
10128
2/2
✓ Branch 0 taken 435420 times.
✓ Branch 1 taken 55298340 times.
55733760 for (int32_t q = 0; q < 127; ++q)
10129 {
10130 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10131
1/2
✓ Branch 0 taken 55298340 times.
✗ Branch 1 not taken.
55298340 if (!replay_is_replaying())
10132 key_current_frame[q] = key[q];
10133
10134
2/2
✓ Branch 0 taken 54864342 times.
✓ Branch 1 taken 433998 times.
55298340 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10135
3/4
✓ Branch 0 taken 12595 times.
✓ Branch 1 taken 55285745 times.
✓ Branch 2 taken 12595 times.
✗ Branch 3 not taken.
55298340 if (KeyPress[q] && q == KEY_B) {
10136 int lol = 1;
10137 }
10138 55298340 KeyInput[q] = key_current_frame[q];
10139 55298340 key_previous_frame[q] = key_current_frame[q];
10140 55298340 }
10141 435420 }
10142
10143 bool zc_disablekey(int32_t k, bool val)
10144 {
10145 switch(k)
10146 {
10147 case KEY_F7:
10148 case KEY_F8:
10149 case KEY_F9:
10150 return false;
10151
10152 default:
10153 disabledKeys[k] = val;
10154 return true;
10155 }
10156 }
10157
10158 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10159 {
10160 timer=timer;
10161 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10162 }
10163
10164 // these are here so that copy_dialog won't choke when compiling zelda
10165 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10166 {
10167 return D_O_K;
10168 }
10169
10170 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10171 {
10172 return D_O_K;
10173 }
10174
10175 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10176 {
10177 return D_O_K;
10178 }
10179
10180 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10181 {
10182 return D_O_K;
10183 }
10184
10185 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10186 {
10187 return D_O_K;
10188 }
10189
10190 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10191 {
10192 return D_O_K;
10193 }
10194
10195 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10196 {
10197 return D_O_K;
10198 }
10199
10200 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10201 {
10202 return D_O_K;
10203 }
10204
10205 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10206 {
10207 return D_O_K;
10208 }
10209
10210 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10211 {
10212 return D_O_K;
10213 }
10214
10215 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10216 {
10217 return D_O_K;
10218 }
10219
10220 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10221 {
10222 return D_O_K;
10223 }
10224
10225 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10226 {
10227 return D_O_K;
10228 }
10229
10230 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10231 {
10232 return D_O_K;
10233 }
10234
10235 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10236 {
10237 return D_O_K;
10238 }
10239
10240 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10241 {
10242 return D_O_K;
10243 }
10244
10245 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10246 {
10247 return D_O_K;
10248 }
10249
10250 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10251 {
10252 return D_O_K;
10253 }
10254
10255 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10256 {
10257 return D_O_K;
10258 }
10259
10260 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10261 {
10262 return D_O_K;
10263 }
10264
10265 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10266 {
10267 return D_O_K;
10268 }
10269
10270 /*** end of zc_sys.cc ***/
10271
10272